diff options
author | Jo-Philipp Wich <jo@mein.io> | 2021-02-17 16:04:46 +0100 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2021-02-17 16:04:46 +0100 |
commit | 14e46b8e225dc329f4e14777960b10abb8a09699 (patch) | |
tree | e55752bae52bf7eed38b91c42e990a8b116b6621 /tests | |
parent | 6d7662f846e031ac52d609dc69349a1816d8e100 (diff) |
syntax: support ES2015 computed property names
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/00_syntax/13_object_literals | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/00_syntax/13_object_literals b/tests/00_syntax/13_object_literals index e7926ad..18fbbed 100644 --- a/tests/00_syntax/13_object_literals +++ b/tests/00_syntax/13_object_literals @@ -127,3 +127,48 @@ In line 2, byte 14: 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 -- |