diff --git a/contrib/geshi/chaiscript.php b/contrib/geshi/chaiscript.php index 1fc6dea..06e4328 100644 --- a/contrib/geshi/chaiscript.php +++ b/contrib/geshi/chaiscript.php @@ -48,7 +48,7 @@ $language_data = array ( 'ESCAPE_CHAR' => '\\', 'KEYWORDS' => array( 1 => array( - 'break', 'else', 'else if', 'eval', 'for', 'if', 'return', 'while', 'try', 'catch', 'finally', 'switch', 'case', 'default', + 'break', 'else', 'else if', 'eval', 'for', 'if', 'return', 'while', 'try', 'catch', 'finally', 'case', 'switch', 'default', ), 2 => array( 'def', 'false', 'fun', 'true', 'var', 'auto', 'attr', diff --git a/include/chaiscript/language/chaiscript_eval.hpp b/include/chaiscript/language/chaiscript_eval.hpp index 7f67257..f2e908d 100644 --- a/include/chaiscript/language/chaiscript_eval.hpp +++ b/include/chaiscript/language/chaiscript_eval.hpp @@ -870,6 +870,7 @@ namespace chaiscript } }; + struct Inline_Array_AST_Node : public AST_Node { public: Inline_Array_AST_Node(const std::string &t_ast_node_text = "", int t_id = AST_Node_Type::Inline_Array, const std::shared_ptr &t_fname=std::shared_ptr(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) : diff --git a/unittests/switch_break.chai b/unittests/switch_break.chai new file mode 100644 index 0000000..8d36275 --- /dev/null +++ b/unittests/switch_break.chai @@ -0,0 +1,22 @@ +var total = 0; + +switch(2) { + case (1) { + total += 1; + break; + } + case (2) { + total += 2; + break; + } + case (3) { + total += 4; + break; + } + case (4) { + total += 8; + break; + } +} + +assert_equal(total, 2) diff --git a/unittests/switch_default.chai b/unittests/switch_default.chai new file mode 100644 index 0000000..8c48aa5 --- /dev/null +++ b/unittests/switch_default.chai @@ -0,0 +1,18 @@ +var total = 0; + +switch(2) { + case (1) { + total += 1; + } + case (3) { + total += 4; + } + case (4) { + total += 8; + } + default { + total += 16; + } +} + +assert_equal(total, 16) diff --git a/unittests/switch_empty.chai b/unittests/switch_empty.chai new file mode 100644 index 0000000..8d3a166 --- /dev/null +++ b/unittests/switch_empty.chai @@ -0,0 +1,4 @@ +switch(true) { } + +// We just have to get here without error for success +assert_equal(true, true); diff --git a/unittests/switch_fallthru.chai b/unittests/switch_fallthru.chai new file mode 100644 index 0000000..627b649 --- /dev/null +++ b/unittests/switch_fallthru.chai @@ -0,0 +1,18 @@ +var total = 0; + +switch(2) { + case (1) { + total += 1; + } + case (2) { + total += 2; + } + case (3) { + total += 4; + } + case (4) { + total += 8; + } +} + +assert_equal(total, 14); diff --git a/unittests/switch_fallthru_and_break.chai b/unittests/switch_fallthru_and_break.chai new file mode 100644 index 0000000..3c93071 --- /dev/null +++ b/unittests/switch_fallthru_and_break.chai @@ -0,0 +1,19 @@ +var total = 0; + +switch(2) { + case (1) { + total += 1; + } + case (2) { + total += 2; + } + case (3) { + total += 4; + break; + } + case (4) { + total += 8; + } +} + +assert_equal(total, 6)