summaryrefslogtreecommitdiffhomepage
path: root/tests/00_syntax
diff options
context:
space:
mode:
Diffstat (limited to 'tests/00_syntax')
-rw-r--r--tests/00_syntax/05_block_nesting7
-rw-r--r--tests/00_syntax/13_object_literals82
-rw-r--r--tests/00_syntax/16_for_loop23
-rw-r--r--tests/00_syntax/17_while_loop2
-rw-r--r--tests/00_syntax/19_arrow_functions6
-rw-r--r--tests/00_syntax/21_regex_literals2
6 files changed, 107 insertions, 15 deletions
diff --git a/tests/00_syntax/05_block_nesting b/tests/00_syntax/05_block_nesting
index 7b74adb..fcfd7da 100644
--- a/tests/00_syntax/05_block_nesting
+++ b/tests/00_syntax/05_block_nesting
@@ -8,6 +8,13 @@ In line 2, byte 61:
Near here --------------------------------------------------^
+Syntax error: Template blocks may not be nested
+In line 3, byte 61:
+
+ `We may not nest expression blocks into statement blocks: {% {{ 1 + 2 }} %}.`
+ Near here --------------------------------------------------^
+
+
-- End --
-- Testcase --
diff --git a/tests/00_syntax/13_object_literals b/tests/00_syntax/13_object_literals
index 60c9f32..18fbbed 100644
--- a/tests/00_syntax/13_object_literals
+++ b/tests/00_syntax/13_object_literals
@@ -48,6 +48,7 @@ either JSON or JavaScript notation.
print(another_obj, "\n");
print(third_obj, "\n");
print(nested_obj, "\n");
+%}
-- End --
@@ -90,3 +91,84 @@ of object properties into other objects.
]), "\n");
%}
-- End --
+
+
+ES2015 short hand property notation is supported as well.
+
+-- Expect stdout --
+{ "a": 123, "b": true, "c": "test" }
+-- End --
+
+-- Testcase --
+{%
+ a = 123;
+ b = true;
+ c = "test";
+
+ o = { a, b, c };
+
+ print(o, "\n");
+%}
+-- End --
+
+-- Expect stderr --
+Syntax error: Unexpected token
+Expecting ':'
+In line 2, byte 14:
+
+ ` o = { "foo" };`
+ Near here ------^
+
+
+-- End --
+
+-- Testcase --
+{%
+ o = { "foo" };
+%}
+-- End --
+
+
+ES2015 computed property names are supported.
+
+-- Expect stdout --
+{ "test": true, "hello": false, "ABC": 123 }
+-- End --
+
+-- Testcase --
+{%
+ s = "test";
+ o = {
+ [s]: true,
+ ["he" + "llo"]: false,
+ [uc("abc")]: 123
+ };
+
+ print(o, "\n");
+%}
+-- End --
+
+-- Expect stderr --
+Syntax error: Expecting expression
+In line 2, byte 10:
+
+ ` o1 = { []: true };`
+ Near here --^
+
+
+Syntax error: Unexpected token
+Expecting ']'
+In line 3, byte 14:
+
+ ` o2 = { [true, false]: 123 };`
+ Near here ------^
+
+
+-- End --
+
+-- Testcase --
+{%
+ o1 = { []: true };
+ o2 = { [true, false]: 123 };
+%}
+-- End --
diff --git a/tests/00_syntax/16_for_loop b/tests/00_syntax/16_for_loop
index 33d1d97..67edc21 100644
--- a/tests/00_syntax/16_for_loop
+++ b/tests/00_syntax/16_for_loop
@@ -218,11 +218,12 @@ Ensure that for-in loop expressions with more than two variables are
rejected.
-- Expect stderr --
-Syntax error: Invalid for-in expression
-In line 2, byte 14:
+Syntax error: Unexpected token
+Expecting ';'
+In line 2, byte 24:
` for (let x, y, z in {})`
- Near here ------^
+ Near here ----------------^
-- End --
@@ -238,11 +239,12 @@ In line 2, byte 14:
Ensure that assignments in for-in loop expressions are rejected.
-- Expect stderr --
-Syntax error: Invalid for-in expression
-In line 2, byte 13:
+Syntax error: Unexpected token
+Expecting ';'
+In line 2, byte 25:
` for (let x = 1, y in {})`
- Near here -----^
+ Near here -----------------^
-- End --
@@ -259,7 +261,7 @@ Ensure that too short for-in loop expressions are rejected (1/2).
-- Expect stderr --
Syntax error: Unexpected token
-Expecting ',' or 'in'
+Expecting ';'
In line 2, byte 12:
` for (let x)`
@@ -279,11 +281,12 @@ In line 2, byte 12:
Ensure that too short for-in loop expressions are rejected (2/2).
-- Expect stderr --
-Syntax error: Invalid for-in expression
-In line 2, byte 14:
+Syntax error: Unexpected token
+Expecting ';'
+In line 2, byte 15:
` for (let x, y)`
- Near here ------^
+ Near here -------^
-- End --
diff --git a/tests/00_syntax/17_while_loop b/tests/00_syntax/17_while_loop
index 4dfaccc..1e68d6b 100644
--- a/tests/00_syntax/17_while_loop
+++ b/tests/00_syntax/17_while_loop
@@ -32,7 +32,7 @@ Iteration 8
Iteration 9
A counting while-loop using the alternative syntax:
-Iteration null
+Iteration 0
Iteration 1
Iteration 2
Iteration 3
diff --git a/tests/00_syntax/19_arrow_functions b/tests/00_syntax/19_arrow_functions
index 4847d8a..102c527 100644
--- a/tests/00_syntax/19_arrow_functions
+++ b/tests/00_syntax/19_arrow_functions
@@ -108,11 +108,11 @@ subsequent testcase asserts that case.
-- Expect stderr --
Syntax error: Unexpected token
-Expecting Label
-In line 2, byte 5:
+Expecting ';'
+In line 2, byte 10:
` (a + 1) => { print("test\n") }`
- ^-- Near here
+ Near here --^
-- End --
diff --git a/tests/00_syntax/21_regex_literals b/tests/00_syntax/21_regex_literals
index 4aef33f..3af53bb 100644
--- a/tests/00_syntax/21_regex_literals
+++ b/tests/00_syntax/21_regex_literals
@@ -35,7 +35,7 @@ Testing invalid flag characters.
-- Expect stderr --
Syntax error: Unexpected token
-Expecting ',' or ';'
+Expecting ';'
In line 2, byte 8:
` /test/x`