diff --git a/jerry-core/parser/js/js-parser-expr.c b/jerry-core/parser/js/js-parser-expr.c index c05f9308e..90ee7ed97 100644 --- a/jerry-core/parser/js/js-parser-expr.c +++ b/jerry-core/parser/js/js-parser-expr.c @@ -267,9 +267,10 @@ parser_emit_unary_lvalue_opcode (parser_context_t *context_p, /**< context */ #if ENABLED (JERRY_ESNEXT) parser_check_invalid_new_target (context_p, opcode); -#endif /* ENABLED (JERRY_ESNEXT) */ - + parser_raise_error (context_p, PARSER_ERR_INVALID_LHS_POSTFIX_OP); +#else /* ENABLED (JERRY_ESNEXT) */ parser_emit_cbc_ext (context_p, CBC_EXT_THROW_REFERENCE_ERROR); +#endif /* ENABLED (JERRY_ESNEXT) */ } parser_emit_cbc (context_p, (uint16_t) opcode); @@ -2637,12 +2638,13 @@ parser_append_binary_single_assignment_token (parser_context_t *context_p, /**< #endif /* ENABLED (JERRY_ESNEXT) */ else { - /* Invalid LeftHandSide expression. */ + /* Invalid LeftHandSide expression. */ //3820, 3815 #if ENABLED (JERRY_ESNEXT) parser_check_invalid_new_target (context_p, CBC_ASSIGN); -#endif /* ENABLED (JERRY_ESNEXT) */ - + parser_raise_error (context_p, PARSER_ERR_INVALID_LHS_ASSIGNMENT); +#else /* !ENABLED (JERRY_ESNEXT) */ parser_emit_cbc_ext (context_p, CBC_EXT_THROW_REFERENCE_ERROR); +#endif /* ENABLED (JERRY_ESNEXT) */ } parser_stack_push_uint8 (context_p, assign_opcode); @@ -2692,9 +2694,11 @@ parser_append_binary_token (parser_context_t *context_p) /**< context */ /* Invalid LeftHandSide expression. */ #if ENABLED (JERRY_ESNEXT) parser_check_invalid_new_target (context_p, CBC_ASSIGN); -#endif /* ENABLED (JERRY_ESNEXT) */ - + parser_raise_error (context_p, PARSER_ERR_INVALID_LHS_ASSIGNMENT); +#else /* !ENABLED (JERRY_ES2015) */ parser_emit_cbc_ext (context_p, CBC_EXT_THROW_REFERENCE_ERROR); +#endif /* ENABLED (JERRY_ES2015) */ + parser_emit_cbc (context_p, CBC_PUSH_PROP_REFERENCE); } } diff --git a/jerry-core/parser/js/js-parser-statm.c b/jerry-core/parser/js/js-parser-statm.c index e6d1da5ec..ce381ccc9 100644 --- a/jerry-core/parser/js/js-parser-statm.c +++ b/jerry-core/parser/js/js-parser-statm.c @@ -1169,7 +1169,12 @@ parser_check_left_hand_side_expression (parser_context_t *context_p, /**< contex else { /* Invalid LeftHandSide expression. */ +#if ENABLED (JERRY_ESNEXT) + parser_raise_error (context_p, PARSER_ERR_INVALID_LHS_FOR_LOOP); +#else /* !ENABLED (JERRY_ESNEXT) */ parser_emit_cbc_ext (context_p, CBC_EXT_THROW_REFERENCE_ERROR); +#endif /* ENABLED (JERRY_ESNEXT) */ + return CBC_ASSIGN; } diff --git a/jerry-core/parser/js/js-parser-util.c b/jerry-core/parser/js/js-parser-util.c index ba1be0a2d..f8360d33a 100644 --- a/jerry-core/parser/js/js-parser-util.c +++ b/jerry-core/parser/js/js-parser-util.c @@ -968,6 +968,18 @@ parser_error_to_string (parser_error_t error) /**< error code */ { return "Duplicate __proto__ fields are not allowed in object literals."; } + case PARSER_ERR_INVALID_LHS_ASSIGNMENT: + { + return "Invalid left-hand side in assignment."; + } + case PARSER_ERR_INVALID_LHS_POSTFIX_OP: + { + return "Invalid left-hand side expression in postfix operation."; + } + case PARSER_ERR_INVALID_LHS_FOR_LOOP: + { + return "Invalid left-hand-side in for-loop."; + } #endif /* ENABLED (JERRY_ESNEXT) */ case PARSER_ERR_DELETE_IDENT_NOT_ALLOWED: { diff --git a/jerry-core/parser/js/js-parser.h b/jerry-core/parser/js/js-parser.h index b950700c2..49b21a26f 100644 --- a/jerry-core/parser/js/js-parser.h +++ b/jerry-core/parser/js/js-parser.h @@ -85,6 +85,9 @@ typedef enum PARSER_ERR_FOR_AWAIT_NO_ASYNC, /**< for-await-of is only allowed inside async functions */ PARSER_ERR_FOR_AWAIT_NO_OF, /**< only 'of' form is allowed for for-await loops */ PARSER_ERR_DUPLICATED_PROTO, /**< duplicated __proto__ fields are not allowed */ + PARSER_ERR_INVALID_LHS_ASSIGNMENT, /**< invalid LeftHandSide in assignment */ + PARSER_ERR_INVALID_LHS_POSTFIX_OP, /**< invalid LeftHandSide expression in postfix operation */ + PARSER_ERR_INVALID_LHS_FOR_LOOP, /**< invalid LeftHandSide in for-loop */ #endif /* ENABLED (JERRY_ESNEXT) */ PARSER_ERR_DELETE_IDENT_NOT_ALLOWED, /**< identifier delete is not allowed in strict mode */ PARSER_ERR_EVAL_CANNOT_ASSIGNED, /**< eval cannot be assigned in strict mode */ diff --git a/tests/jerry/es.next/arithmetic-parse.js b/tests/jerry/es.next/arithmetic-parse.js new file mode 100644 index 000000000..f1ddcf2ac --- /dev/null +++ b/tests/jerry/es.next/arithmetic-parse.js @@ -0,0 +1,92 @@ +// Copyright JS Foundation and other contributors, http://js.foundation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +function check_syntax_error (txt) { + try { + eval (txt) + assert (false) + } catch (e) { + assert (e instanceof SyntaxError) + } +} + +var a = 21; +var b = 10; +var c; + +check_syntax_error ("c = a++b"); +check_syntax_error ("c = a--b"); + +check_syntax_error ("c = a +* b"); +check_syntax_error ("c = a -* b"); +check_syntax_error ("c = a +/ b"); +check_syntax_error ("c = a -/ b"); +check_syntax_error ("c = a +% b"); +check_syntax_error ("c = a -% b"); + +check_syntax_error ("a =* b"); +check_syntax_error ("a =/ b"); +check_syntax_error ("a =% b"); + +check_syntax_error ("c = a+"); +check_syntax_error ("c = a-"); + +check_syntax_error("a++\n()"); +check_syntax_error("a--\n.b"); + +assert((-2 .toString()) === -2); + +Number.prototype[0] = 123; +assert(-2[0] === -123); + +function f() { + var a = 0; + function g() {} + + try { + eval ("g(this, 'a' = 1)"); + assert (false); + } catch (e) { + assert (e instanceof SyntaxError); + } + + try { + eval ("g(this, 'a' += 1)"); + assert (false); + } catch (e) { + assert (e instanceof SyntaxError); + } + + assert (a === 0); +} +f(); + +function g(a, b) +{ + assert(b === "undefined"); +} +g(this, typeof undeclared_var) + +function h() +{ + var done = false; + var o = { a: function () { done = (this === o) } } + function f() {} + + with (o) { + f(this, a()); + } + assert(done); +} +h(); diff --git a/tests/jerry/es.next/arithmetics-2.js b/tests/jerry/es.next/arithmetics-2.js new file mode 100644 index 000000000..9ce14da21 --- /dev/null +++ b/tests/jerry/es.next/arithmetics-2.js @@ -0,0 +1,55 @@ +// Copyright JS Foundation and other contributors, http://js.foundation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +var a = 21; +var b = 10; +var c; + +c = a + b; +assert(c == 31); + +c = a - b; +assert(c == 11); + +c = a * b; +assert(c == 210); + +c = a / b; +assert(c >= 2.1 - 0.000001 && c <= 2.1 + 0.000001); + +c = a % b; +assert(c == 1); + +c = a++; +assert(c == 21); + +c = a--; +assert(c == 22); + +var o = { p : 1 }; + +assert (++o.p === 2); +assert (o.p === 2); +assert (--o.p === 1); +assert (o.p === 1); + +try { + eval ('++ ++ a'); + assert (false); +} +catch (e) { + assert (e instanceof SyntaxError); +} + +assert (0.1 + 0.2 != 0.3); diff --git a/tests/jerry/es.next/array-pattern.js b/tests/jerry/es.next/array-pattern.js index c2e3a90a7..ff7a75d52 100644 --- a/tests/jerry/es.next/array-pattern.js +++ b/tests/jerry/es.next/array-pattern.js @@ -309,5 +309,5 @@ try { eval ("var a = 0; 1 + [a] = [1]"); assert (false); } catch (e) { - assert (e instanceof ReferenceError); + assert (e instanceof SyntaxError); } diff --git a/tests/jerry/es.next/object-pattern.js b/tests/jerry/es.next/object-pattern.js index 3db8a1c71..e55aae2af 100644 --- a/tests/jerry/es.next/object-pattern.js +++ b/tests/jerry/es.next/object-pattern.js @@ -230,5 +230,5 @@ try { eval ("var a = 0; -{a} = {a:1}"); assert (false); } catch (e) { - assert (e instanceof ReferenceError); + assert (e instanceof SyntaxError); } diff --git a/tests/jerry/es.next/parser-additive-op-assign.js b/tests/jerry/es.next/parser-additive-op-assign.js new file mode 100644 index 000000000..5ae9b07b4 --- /dev/null +++ b/tests/jerry/es.next/parser-additive-op-assign.js @@ -0,0 +1,206 @@ +/* Copyright JS Foundation and other contributors, http://js.foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// tests for ECMA~262 v6 12.7.2 + +var tests = [ + // this + 'this + this = 42', + 'this + null = 42', + 'this + undefined = 42', + 'this + true = 42', + 'this + 12 = 42', + 'this + "foo" = 42', + 'this + [12] = 42', + 'this + {} = 42', + 'this + class a {} = 42', + 'this + function a(){} = 42', + 'this + /[a]/ = 42', + 'this + `foo` = 42', + 'this - this = 42', + 'this - null = 42', + 'this - undefined = 42', + 'this - true = 42', + 'this - 12 = 42', + 'this - "foo" = 42', + 'this - [12] = 42', + 'this - {} = 42', + 'this - class a {} = 42', + 'this - function a(){} = 42', + 'this - /[a]/ = 42', + 'this - `foo` = 42', + // undefined + 'undefined + null = 42', + 'undefined + undefined = 42', + 'undefined + true = 42', + 'undefined + 12 = 42', + 'undefined + "foo" = 42', + 'undefined + [12] = 42', + 'undefined + {} = 42', + 'undefined + class a {} = 42', + 'undefined + function a(){} = 42', + 'undefined + /[a]/ = 42', + 'undefined + `foo` = 42', + 'undefined - null = 42', + 'undefined - undefined = 42', + 'undefined - true = 42', + 'undefined - 12 = 42', + 'undefined - "foo" = 42', + 'undefined - [12] = 42', + 'undefined - {} = 42', + 'undefined - class a {} = 42', + 'undefined - function a(){} = 42', + 'undefined - /[a]/ = 42', + 'undefined - `foo` = 42', + // NullLiteral + 'null + null = 42', + 'null + true = 42', + 'null + 12 = 42', + 'null + "foo" = 42', + 'null + [12] = 42', + 'null + {} = 42', + 'null + class a {} = 42', + 'null + function a(){} = 42', + 'null + /[a]/ = 42', + 'null + `foo` = 42', + 'null - null = 42', + 'null - true = 42', + 'null - 12 = 42', + 'null - "foo" = 42', + 'null - [12] = 42', + 'null - {} = 42', + 'null - class a {} = 42', + 'null - function a(){} = 42', + 'null - /[a]/ = 42', + 'null - `foo` = 42', + // BooleanLiteral + 'true + true = 42', + 'true + 12 = 42', + 'true + "foo" = 42', + 'true + [12] = 42', + 'true + {} = 42', + 'true + class a {} = 42', + 'true + function a(){} = 42', + 'true + /[a]/ = 42', + 'true + `foo` = 42', + 'true - true = 42', + 'true - 12 = 42', + 'true - "foo" = 42', + 'true - [12] = 42', + 'true - {} = 42', + 'true - class a {} = 42', + 'true - function a(){} = 42', + 'true - /[a]/ = 42', + 'true - `foo` = 42', + // DecimalLiteral + '5 + 12 = 42', + '5 + "foo" = 42', + '5 + [12] = 42', + '5 + {} = 42', + '5 + class a {} = 42', + '5 + function a(){} = 42', + '5 + /[a]/ = 42', + '5 + `foo` = 42', + '5 - 12 = 42', + '5 - "foo" = 42', + '5 - [12] = 42', + '5 - {} = 42', + '5 - class a {} = 42', + '5 - function a(){} = 42', + '5 - /[a]/ = 42', + '5 - `foo` = 42', + // StringLiteral + '"foo" + "foo" = 42', + '"foo" + [12] = 42', + '"foo" + {} = 42', + '"foo" + class a {} = 42', + '"foo" + function a(){} = 42', + '"foo" + /[a]/ = 42', + '"foo" + `foo` = 42', + '"foo" - "foo" = 42', + '"foo" - [12] = 42', + '"foo" - {} = 42', + '"foo" - class a {} = 42', + '"foo" - function a(){} = 42', + '"foo" - /[a]/ = 42', + '"foo" - `foo` = 42', + // ArrayLiteral + '[12] + [12] = 42', + '[12] + {} = 42', + '[12] + class a {} = 42', + '[12] + function a(){} = 42', + '[12] + /[a]/ = 42', + '[12] + `foo` = 42', + '[12] - [12] = 42', + '[12] - {} = 42', + '[12] - class a {} = 42', + '[12] - function a(){} = 42', + '[12] - /[a]/ = 42', + '[12] - `foo` = 42', + // ObjectLiteral + '{} + {} = 42', + '{} + class a {} = 42', + '{} + function a(){} = 42', + '{} + /[a]/ = 42', + '{} + `foo` = 42', + '{} - {} = 42', + '{} - class a {} = 42', + '{} - function a(){} = 42', + '{} - /[a]/ = 42', + '{} - `foo` = 42', + // ClassExpression + 'class a {} + class b {} = 42', + 'class a {} + function a(){} = 42', + 'class a {} + /[a]/ = 42', + 'class a {} + `foo` = 42', + 'class a {} - class b {} = 42', + 'class a {} - function a(){} = 42', + 'class a {} - /[a]/ = 42', + 'class a {} - `foo` = 42', + // RegularExpressionLiteral + '/[a]/ + function a(){} = 42', + '/[a]/ + /[a]/ = 42', + '/[a]/ + `foo` = 42', + '/[a]/ - function a(){} = 42', + '/[a]/ - /[a]/ = 42', + '/[a]/ - `foo` = 42', + // TemplateLiteral + '`foo` + function a(){} = 42', + '`foo` + `foo` = 42', + '`foo` - function a(){} = 42', + '`foo` - `foo` = 42', + // combining with MultiplicativeExpression + '6 * 6 + !4 / 7 = 42', + '-6 * !6 - ~4 / "foo" = 42', + '~"foo" * void 12 % 6 = 42', + 'typeof [] * 8 * [] / !function a(){} = 42', + '+[2] % /foo/ + !undefined - +"[1,2]" = 42', + 'var a = 5; ++a * "foo" + function a(){} = 42', + '+/(?:)/ % 25 + void 6 / typeof class a {} = 42', + 'function a(){}; var b = new a(); ++a / !23 - !a = 42', + 'var a = {"foo": function(){}}; void "foo" % 12 - typeof a.foo = 42', + 'var a = {"foo": function(){}}; void "foo" % 12 + typeof a.foo() = 42', + 'var a = [1,2,3]; !a[0] % /[A]/ + delete 12 = 42', +]; + +for (var i = 0; i < tests.length; i++) +{ + try { + eval(tests[i]); + assert(false); + } catch (e) { + assert(e instanceof SyntaxError); + } +} diff --git a/tests/jerry/es.next/parser-binary-bitwise-op-assign-1.js b/tests/jerry/es.next/parser-binary-bitwise-op-assign-1.js new file mode 100644 index 000000000..d944a3abf --- /dev/null +++ b/tests/jerry/es.next/parser-binary-bitwise-op-assign-1.js @@ -0,0 +1,120 @@ +/* Copyright JS Foundation and other contributors, http://js.foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// tests for ECMA~262 v6 12.11.2 & operation + +var tests = [ + // this + 'this & this = 42', + 'this & null = 42', + 'this & undefined = 42', + 'this & true = 42', + 'this & 12 = 42', + 'this & "foo" = 42', + 'this & [12] = 42', + 'this & class a {} = 42', + 'this & function a(){} = 42', + 'this & /[a]/ = 42', + 'this & `foo` = 42', + // undefined + 'undefined & null = 42', + 'undefined & undefined = 42', + 'undefined & true = 42', + 'undefined & 12 = 42', + 'undefined & "foo" = 42', + 'undefined & [12] = 42', + 'undefined & class a {} = 42', + 'undefined & function a(){} = 42', + 'undefined & /[a]/ = 42', + 'undefined & `foo` = 42', + // NullLiteral + 'null & null = 42', + 'null & true = 42', + 'null & 12 = 42', + 'null & "foo" = 42', + 'null & [12] = 42', + 'null & class a {} = 42', + 'null & function a(){} = 42', + 'null & /[a]/ = 42', + 'null & `foo` = 42', + // BooleanLiteral + 'true & true = 42', + 'true & 12 = 42', + 'true & "foo" = 42', + 'true & [12] = 42', + 'true & class a {} = 42', + 'true & function a(){} = 42', + 'true & /[a]/ = 42', + 'true & `foo` = 42', + // DecimalLiteral + '5 & 12 = 42', + '5 & "foo" = 42', + '5 & [12] = 42', + '5 & class a {} = 42', + '5 & function a(){} = 42', + '5 & /[a]/ = 42', + '5 & `foo` = 42', + // StringLiteral + '"foo" & "foo" = 42', + '"foo" & [12] = 42', + '"foo" & class a {} = 42', + '"foo" & function a(){} = 42', + '"foo" & /[a]/ = 42', + '"foo" & `foo` = 42', + // ArrayLiteral + '[12] & [12] = 42', + '[12] & class a {} = 42', + '[12] & function a(){} = 42', + '[12] & /[a]/ = 42', + '[12] & `foo` = 42', + // ObjectLiteral + 'this & {} = 42', + 'undefined & {} = 42', + 'null & {} = 42', + 'true & {} = 42', + '5 & {} = 42', + '"foo" & {} = 42', + '[12] & {} = 42', + '/[a]/ & {} = 42', + '`foo` & {} = 42', + // RegularExpressionLiteral + '/[a]/ & class a{} = 42', + '/[a]/ & function a(){} = 42', + '/[a]/ & /[a]/ = 42', + '/[a]/ & `foo` = 42', + // TemplateLiteral + '`foo` & class a{} = 42', + '`foo` & function a(){} = 42', + '`foo` & `foo` = 42', + // combining with EqualityExpression + '[] << !5 * function a(){} & "foo" == !"foo" % 6 + !4 / 7 = 42', + 'void function a(){} & +6 << /[A]/ + !6 - ~4 / "foo" = 42', + 'var a = 5; 5 << [] * 12 != [1,2,3] & ++a * typeof "foo" & function a(){} = 42', + '`foo` === "foo" & +/(?:)/ % 25 + void 6 % delete class a {} = 42', + 'function a(){}; var b = new a(); 5 & ++a / !23 & !a >> 12 * [] == /foo/ = 42', + 'var a = {"foo": function(){}}; void "foo" % 12 & /[A-Z]/ + 12 >> typeof a.foo != a.foo() = 42', + '4 % [1,2] - class a{} << typeof "foo" == !25 & [] != 13 >> "foo" + delete 3 / /(?:)/ = 42', + 'var a = [1,2,3]; a[2] == "foo" >> [] << typeof class a{} * 12 + void [] / [] != !a[0] % /[A]/ - delete `` & ++a[1] - a[2]-- = 42', +]; + +for (var i = 0; i < tests.length; i++) +{ + try { + eval(tests[i]); + assert(false); + } catch (e) { + assert(e instanceof SyntaxError); + } +} diff --git a/tests/jerry/es.next/parser-binary-bitwise-op-assign-2.js b/tests/jerry/es.next/parser-binary-bitwise-op-assign-2.js new file mode 100644 index 000000000..9c5b8b76d --- /dev/null +++ b/tests/jerry/es.next/parser-binary-bitwise-op-assign-2.js @@ -0,0 +1,120 @@ +/* Copyright JS Foundation and other contributors, http://js.foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// tests for ECMA~262 v6 12.11.2 ^ operation + +var tests = [ + // this + 'this ^ this = 42', + 'this ^ null = 42', + 'this ^ undefined = 42', + 'this ^ true = 42', + 'this ^ 12 = 42', + 'this ^ "foo" = 42', + 'this ^ [12] = 42', + 'this ^ class a {} = 42', + 'this ^ function a(){} = 42', + 'this ^ /[a]/ = 42', + 'this ^ `foo` = 42', + // undefined + 'undefined ^ null = 42', + 'undefined ^ undefined = 42', + 'undefined ^ true = 42', + 'undefined ^ 12 = 42', + 'undefined ^ "foo" = 42', + 'undefined ^ [12] = 42', + 'undefined ^ class a {} = 42', + 'undefined ^ function a(){} = 42', + 'undefined ^ /[a]/ = 42', + 'undefined ^ `foo` = 42', + // NullLiteral + 'null ^ null = 42', + 'null ^ true = 42', + 'null ^ 12 = 42', + 'null ^ "foo" = 42', + 'null ^ [12] = 42', + 'null ^ class a {} = 42', + 'null ^ function a(){} = 42', + 'null ^ /[a]/ = 42', + 'null ^ `foo` = 42', + // BooleanLiteral + 'true ^ true = 42', + 'true ^ 12 = 42', + 'true ^ "foo" = 42', + 'true ^ [12] = 42', + 'true ^ class a {} = 42', + 'true ^ function a(){} = 42', + 'true ^ /[a]/ = 42', + 'true ^ `foo` = 42', + // DecimalLiteral + '5 ^ 12 = 42', + '5 ^ "foo" = 42', + '5 ^ [12] = 42', + '5 ^ class a {} = 42', + '5 ^ function a(){} = 42', + '5 ^ /[a]/ = 42', + '5 ^ `foo` = 42', + // StringLiteral + '"foo" ^ "foo" = 42', + '"foo" ^ [12] = 42', + '"foo" ^ class a {} = 42', + '"foo" ^ function a(){} = 42', + '"foo" ^ /[a]/ = 42', + '"foo" ^ `foo` = 42', + // ArrayLiteral + '[12] ^ [12] = 42', + '[12] ^ class a {} = 42', + '[12] ^ function a(){} = 42', + '[12] ^ /[a]/ = 42', + '[12] ^ `foo` = 42', + // ObjectLiteral + 'this ^ {} = 42', + 'undefined ^ {} = 42', + 'null ^ {} = 42', + 'true ^ {} = 42', + '5 ^ {} = 42', + '"foo" ^ {} = 42', + '[12] ^ {} = 42', + '/[a]/ ^ {} = 42', + '`foo` ^ {} = 42', + // RegularExpressionLiteral + '/[a]/ ^ class a{} = 42', + '/[a]/ ^ function a(){} = 42', + '/[a]/ ^ /[a]/ = 42', + '/[a]/ ^ `foo` = 42', + // TemplateLiteral + '`foo` ^ class a{} = 42', + '`foo` ^ function a(){} = 42', + '`foo` ^ `foo` = 42', + // combining with EqualityExpression + '[] << !5 * function a(){} ^ "foo" == !"foo" % 6 + !4 / 7 = 42', + 'void function a(){} ^ +6 << /[A]/ + !6 - ~4 / "foo" = 42', + 'var a = 5; 5 << [] * 12 != [1,2,3] ^ ++a * typeof "foo" ^ function a(){} = 42', + '`foo` === "foo" ^ +/(?:)/ % 25 + void 6 % delete class a {} = 42', + 'function a(){}; var b = new a(); 5 ^ ++a / !23 ^ !a >> 12 * [] == /foo/ = 42', + 'var a = {"foo": function(){}}; void "foo" % 12 ^ /[A-Z]/ + 12 >> typeof a.foo != a.foo() = 42', + '4 % [1,2] - class a{} << typeof "foo" == !25 ^ [] != 13 >> "foo" + delete 3 / /(?:)/ = 42', + 'var a = [1,2,3]; a[2] == "foo" >> [] << typeof class a{} * 12 + void [] / [] != !a[0] % /[A]/ - delete `` ^ ++a[1] - a[2]-- = 42', +]; + +for (var i = 0; i < tests.length; i++) +{ + try { + eval(tests[i]); + assert(false); + } catch (e) { + assert(e instanceof SyntaxError); + } +} diff --git a/tests/jerry/es.next/parser-binary-bitwise-op-assign-3.js b/tests/jerry/es.next/parser-binary-bitwise-op-assign-3.js new file mode 100644 index 000000000..7b848baeb --- /dev/null +++ b/tests/jerry/es.next/parser-binary-bitwise-op-assign-3.js @@ -0,0 +1,120 @@ +/* Copyright JS Foundation and other contributors, http://js.foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// tests for ECMA~262 v6 12.11.2 | operation + +var tests = [ + // this + 'this | this = 42', + 'this | null = 42', + 'this | undefined = 42', + 'this | true = 42', + 'this | 12 = 42', + 'this | "foo" = 42', + 'this | [12] = 42', + 'this | class a {} = 42', + 'this | function a(){} = 42', + 'this | /[a]/ = 42', + 'this | `foo` = 42', + // undefined + 'undefined | null = 42', + 'undefined | undefined = 42', + 'undefined | true = 42', + 'undefined | 12 = 42', + 'undefined | "foo" = 42', + 'undefined | [12] = 42', + 'undefined | class a {} = 42', + 'undefined | function a(){} = 42', + 'undefined | /[a]/ = 42', + 'undefined | `foo` = 42', + // NullLiteral + 'null | null = 42', + 'null | true = 42', + 'null | 12 = 42', + 'null | "foo" = 42', + 'null | [12] = 42', + 'null | class a {} = 42', + 'null | function a(){} = 42', + 'null | /[a]/ = 42', + 'null | `foo` = 42', + // BooleanLiteral + 'true | true = 42', + 'true | 12 = 42', + 'true | "foo" = 42', + 'true | [12] = 42', + 'true | class a {} = 42', + 'true | function a(){} = 42', + 'true | /[a]/ = 42', + 'true | `foo` = 42', + // DecimalLiteral + '5 | 12 = 42', + '5 | "foo" = 42', + '5 | [12] = 42', + '5 | class a {} = 42', + '5 | function a(){} = 42', + '5 | /[a]/ = 42', + '5 | `foo` = 42', + // StringLiteral + '"foo" | "foo" = 42', + '"foo" | [12] = 42', + '"foo" | class a {} = 42', + '"foo" | function a(){} = 42', + '"foo" | /[a]/ = 42', + '"foo" | `foo` = 42', + // ArrayLiteral + '[12] | [12] = 42', + '[12] | class a {} = 42', + '[12] | function a(){} = 42', + '[12] | /[a]/ = 42', + '[12] | `foo` = 42', + // ObjectLiteral + 'this | {} = 42', + 'undefined | {} = 42', + 'null | {} = 42', + 'true | {} = 42', + '5 | {} = 42', + '"foo" | {} = 42', + '[12] | {} = 42', + '/[a]/ | {} = 42', + '`foo` | {} = 42', + // RegularExpressionLiteral + '/[a]/ | class a{} = 42', + '/[a]/ | function a(){} = 42', + '/[a]/ | /[a]/ = 42', + '/[a]/ | `foo` = 42', + // TemplateLiteral + '`foo` | class a{} = 42', + '`foo` | function a(){} = 42', + '`foo` | `foo` = 42', + // combining with EqualityExpression + '[] << !5 * function a(){} | "foo" == !"foo" % 6 + !4 / 7 = 42', + 'void function a(){} | +6 << /[A]/ + !6 - ~4 / "foo" = 42', + 'var a = 5; 5 << [] * 12 != [1,2,3] | ++a * typeof "foo" | function a(){} = 42', + '`foo` === "foo" | +/(?:)/ % 25 + void 6 % delete class a {} = 42', + 'function a(){}; var b = new a(); 5 | ++a / !23 | !a >> 12 * [] == /foo/ = 42', + 'var a = {"foo": function(){}}; void "foo" % 12 | /[A-Z]/ + 12 >> typeof a.foo != a.foo() = 42', + '4 % [1,2] - class a{} << typeof "foo" == !25 | [] != 13 >> "foo" + delete 3 / /(?:)/ = 42', + 'var a = [1,2,3]; a[2] == "foo" >> [] << typeof class a{} * 12 + void [] / [] != !a[0] % /[A]/ - delete `` | ++a[1] - a[2]-- = 42', +]; + +for (var i = 0; i < tests.length; i++) +{ + try { + eval(tests[i]); + assert(false); + } catch (e) { + assert(e instanceof SyntaxError); + } +} diff --git a/tests/jerry/es.next/parser-binary-logical-op-assign.js b/tests/jerry/es.next/parser-binary-logical-op-assign.js new file mode 100644 index 000000000..328778462 --- /dev/null +++ b/tests/jerry/es.next/parser-binary-logical-op-assign.js @@ -0,0 +1,194 @@ +/* Copyright JS Foundation and other contributors, http://js.foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// tests for ECMA~262 v6 12.12.1 + +var tests = [ + // this + 'this && this = 42', + 'this && null = 42', + 'this && undefined = 42', + 'this && true = 42', + 'this && 12 = 42', + 'this && "foo" = 42', + 'this && [12] = 42', + 'this && class a {} = 42', + 'this && function a(){} = 42', + 'this && /[a]/ = 42', + 'this && `foo` = 42', + 'this || this = 42', + 'this || null = 42', + 'this || undefined = 42', + 'this || true = 42', + 'this || 12 = 42', + 'this || "foo" = 42', + 'this || [12] = 42', + 'this || class a {} = 42', + 'this || function a(){} = 42', + 'this || /[a]/ = 42', + 'this || `foo` = 42', + // undefined + 'undefined && null = 42', + 'undefined && undefined = 42', + 'undefined && true = 42', + 'undefined && 12 = 42', + 'undefined && "foo" = 42', + 'undefined && [12] = 42', + 'undefined && class a {} = 42', + 'undefined && function a(){} = 42', + 'undefined && /[a]/ = 42', + 'undefined && `foo` = 42', + 'undefined || null = 42', + 'undefined || undefined = 42', + 'undefined || true = 42', + 'undefined || 12 = 42', + 'undefined || "foo" = 42', + 'undefined || [12] = 42', + 'undefined || class a {} = 42', + 'undefined || function a(){} = 42', + 'undefined || /[a]/ = 42', + 'undefined || `foo` = 42', + // NullLiteral + 'null && null = 42', + 'null && true = 42', + 'null && 12 = 42', + 'null && "foo" = 42', + 'null && [12] = 42', + 'null && class a {} = 42', + 'null && function a(){} = 42', + 'null && /[a]/ = 42', + 'null && `foo` = 42', + 'null || null = 42', + 'null || true = 42', + 'null || 12 = 42', + 'null || "foo" = 42', + 'null || [12] = 42', + 'null || class a {} = 42', + 'null || function a(){} = 42', + 'null || /[a]/ = 42', + 'null || `foo` = 42', + // BooleanLiteral + 'true && true = 42', + 'true && 12 = 42', + 'true && "foo" = 42', + 'true && [12] = 42', + 'true && class a {} = 42', + 'true && function a(){} = 42', + 'true && /[a]/ = 42', + 'true && `foo` = 42', + 'true || true = 42', + 'true || 12 = 42', + 'true || "foo" = 42', + 'true || [12] = 42', + 'true || class a {} = 42', + 'true || function a(){} = 42', + 'true || /[a]/ = 42', + 'true || `foo` = 42', + // DecimalLiteral + '5 && 12 = 42', + '5 && "foo" = 42', + '5 && [12] = 42', + '5 && class a {} = 42', + '5 && function a(){} = 42', + '5 && /[a]/ = 42', + '5 && `foo` = 42', + '5 || 12 = 42', + '5 || "foo" = 42', + '5 || [12] = 42', + '5 || class a {} = 42', + '5 || function a(){} = 42', + '5 || /[a]/ = 42', + '5 || `foo` = 42', + // StringLiteral + '"foo" && "foo" = 42', + '"foo" && [12] = 42', + '"foo" && class a {} = 42', + '"foo" && function a(){} = 42', + '"foo" && /[a]/ = 42', + '"foo" && `foo` = 42', + '"foo" || "foo" = 42', + '"foo" || [12] = 42', + '"foo" || class a {} = 42', + '"foo" || function a(){} = 42', + '"foo" || /[a]/ = 42', + '"foo" || `foo` = 42', + // ArrayLiteral + '[12] && [12] = 42', + '[12] && class a {} = 42', + '[12] && function a(){} = 42', + '[12] && /[a]/ = 42', + '[12] && `foo` = 42', + '[12] || [12] = 42', + '[12] || class a {} = 42', + '[12] || function a(){} = 42', + '[12] || /[a]/ = 42', + '[12] || `foo` = 42', + // ObjectLiteral + 'this && {} = 42', + 'this || {} = 42', + 'undefined && {} = 42', + 'undefined || {} = 42', + 'null && {} = 42', + 'null || {} = 42', + 'true && {} = 42', + 'true || {} = 42', + '5 && {} = 42', + '5 || {} = 42', + '"foo" && {} = 42', + '"foo" || {} = 42', + '[12] && {} = 42', + '[12] || {} = 42', + '/[a]/ && {} = 42', + '`foo` && {} = 42', + '/[a]/ || {} = 42', + '`foo` || {} = 42', + // RegularExpressionLiteral + '/[a]/ && class a{} = 42', + '/[a]/ && function a(){} = 42', + '/[a]/ && /[a]/ = 42', + '/[a]/ && `foo` = 42', + '/[a]/ || class a{} = 42', + '/[a]/ || function a(){} = 42', + '/[a]/ || /[a]/ = 42', + '/[a]/ || `foo` = 42', + // TemplateLiteral + '`foo` && class a{} = 42', + '`foo` && function a(){} = 42', + '`foo` && `foo` = 42', + '`foo` || class a{} = 42', + '`foo` || function a(){} = 42', + '`foo` || `foo` = 42', + // combining with BitwiseORExpression and LogicalANDExpression + '[] << !5 * function a(){} | "foo" == !"foo" % 6 + !4 / 7 || 23 & +[] >> 4 * delete 12 = 42', + '[] << !5 * function a(){} | "foo" == !"foo" % 6 + !4 / 7 && 23 & +[] >> 4 * delete 12 = 42', + '4 % [1,2] - class a{} << typeof "foo" == !25 | [] != 13 >> "foo" + delete 3 / /(?:)/ || ++a * "foo" + function a(){} = 42', + '4 % [1,2] - class a{} << typeof "foo" == !25 | [] != 13 >> "foo" + delete 3 / /(?:)/ && ++a * "foo" + function a(){} = 42', + '`foo` === "foo" | +/(?:)/ % 25 + void 6 % delete class a {} || 5 >> void function a(){} !== +6 * !6 - ~4 / "foo" = 42', + '`foo` === "foo" | +/(?:)/ % 25 + void 6 % delete class a {} && 5 >> void function a(){} !== +6 * !6 - ~4 / "foo" = 42', + 'var a = 5; 5 + class a{} << typeof "foo" == !25 | [] != 13 >> "foo" + delete 3 || 5 << [] * 12 != [1,2,3] ^ ++a * typeof "foo" ^ function a(){} = 42', + 'var a = 5; 5 + class a{} << typeof "foo" == !25 | [] != 13 >> "foo" + delete 3 && 5 << [] * 12 != [1,2,3] ^ ++a * typeof "foo" ^ function a(){} = 42', + '[1,2] >> +5 * function a(){} ^ !"foo" == !"foo" % ~6 + !4 / void /foo/ || [3] << !5 * function a(){} ^ "foo" == !"foo" % 6 + !0b11 / 0xFF = 42', + '[1,2] >> +5 * function a(){} ^ !"foo" == !"foo" % ~6 + !4 / void /foo/ && [3] << !5 * function a(){} ^ "foo" == !"foo" % 6 + !0b11 / 0xFF = 42', +]; + +for (var i = 0; i < tests.length; i++) +{ + try { + eval(tests[i]); + assert(false); + } catch (e) { + assert(e instanceof SyntaxError); + } +} diff --git a/tests/jerry/es.next/parser-covered-parenthesized-exp-assign.js b/tests/jerry/es.next/parser-covered-parenthesized-exp-assign.js new file mode 100644 index 000000000..cf02c1bb1 --- /dev/null +++ b/tests/jerry/es.next/parser-covered-parenthesized-exp-assign.js @@ -0,0 +1,119 @@ +/* Copyright JS Foundation and other contributors, http://js.foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// tests for ECMA-262 v6 12.2.1.5 and 12.2.10.3 + +var tests = [ + // this + '(this) = 42;', + // NullLiteral + '(null) = 42;', + // BooleanLiteral + '(false) = 42;', + '(true) = 42;', + // DecimalLiteral + '(12) = 42;', + '(0.12) = 42;', + '(.12) = 42;', + '(1.23e4) = 42;', + '(.23e-2) = 42;', + // BinaryIntegerLiteral + '(0b11) = 42; ', + '(0B11) = 42;', + // OctalIntegerLiteral + '(0o67) = 42;', + '(0O67) = 42;', + // HexIntegerLiteral + '(0xDD) = 42;', + '(0XDD) = 42;', + // StringLiteral + '("foo") = 42;', + '(\'foo\') = 42;', + '("\\n") = 42;', + '(\'\\n\') = 42;', + '("\\0") = 42;', + '(\'\\0\') = 42;', + '("\\x0F") = 42;', + '(\'\\x0F\') = 42;', + '("\\uFFFF") = 42;', + '(\'\\uFFFF\') = 42;', + '("\\u{F}") = 42;', + '(\'\\u{F}\') = 42;', + '("\\d") = 42;', + '(\'\\d\') = 42;', + '("\\u000A") = 42;', + '(\'\\u000A\') = 42;', + // ArrayLiteral + '([]) = 42;', + '([1]) = 42;', + '([1,,]) = 42;', + '([1,a=5]) = 42;', + // ObjectLiteral + '({}) = 42;', + '({yield}) = 42;', + '({$a}) = 42;', + '({a}) = 42;', + '({a : 5}) = 42;', + '({5 : 5}) = 42;', + '({"foo" : 5}) = 42;', + '({[key] : 5}) = 42;', + '({func(){}}) = 42;', + '({get(){}}) = 42;', + '({set(prop){}}) = 42;', + '({*func(){}}) = 42;', + // FunctionExpression + '(function(){}) = 42;', + '(function(...a){}) = 42;', + '(function a(){}) = 42;', + '(function a(...a){}) = 42;', + '(function (a){}) = 42;', + '(function a(a){}) = 42;', + // ClassExpression + '(class a {}) = 42;', + 'class b {}; (class a extends b {}) = 42;', + '(class a {function(){}}) = 42;', + // GeneratorExpression + '(function *a (){}) = 42;', + // RegularExpressionLiteral + '(/(?:)/) = 42;', + '(/a/) = 42;', + '(/\\a/) = 42;', + '(/[a]/) = 42;', + '(/a/g) = 42;', + '(/a/i) = 42;', + '(/a/m) = 42;', + '(/a/u) = 42;', + '(/a/y) = 42;', + // TemplateLiteral + '(``) = 42;', + 'a = 5; (`${a}`) = 42;', + '(`\\a`) = 42;', + '(`\\0`) = 42;', + '(`\\xFF`) = 42;', + '(`\\uFFFF`) = 42;', + '(`\\u{F}`) = 42;', + '(`foo`) = 42;', + '(`\\u000A`) = 42;', +]; + +for (var i = 0; i < tests.length; i++) +{ + try { + eval(tests[i]); + assert(false); + } catch (e) { + assert(e instanceof SyntaxError); + } +} diff --git a/tests/jerry/es.next/parser-delete-op-assign.js b/tests/jerry/es.next/parser-delete-op-assign.js new file mode 100644 index 000000000..125f83573 --- /dev/null +++ b/tests/jerry/es.next/parser-delete-op-assign.js @@ -0,0 +1,97 @@ +/* Copyright JS Foundation and other contributors, http://js.foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// tests for ECMA-262 v6 12.5.3 delete UnaryExpression + +var tests = [ + // IdentifierReference + 'var obj = {a : 10, ret : function(params) {delete a = 42;}}', + // NullLiteral + 'var a = null; delete a = 42', + // BooleanLiteral + 'var a = true; delete a = 42', + 'var a = false; delete a = 42', + // DecimalLiteral + 'var a = 5; delete a = 42', + 'var a = 1.23e4; delete a = 42', + // BinaryIntegerLiteral + 'var a = 0b11; delete a = 42', + 'var a = 0B11; delete a = 42', + // OctalIntegerLiteral + 'var a = 0o66; delete a = 42', + 'var a = 0O66; delete a = 42', + // HexIntegerLiteral + 'var a = 0xFF; delete a = 42', + 'var a = 0xFF; delete a = 42', + // StringLiteral + 'var a = "foo"; delete a = 42', + 'var a = "\\n"; delete a = 42', + 'var a = "\\uFFFF"; delete a = 42', + 'var a ="\\u{F}"; delete a = 42', + // ArrayLiteral + 'var a = []; delete a = 42', + 'var a = [1,a=5]; delete a = 42', + // ObjectLiteral + 'var a = {}; delete a = 42', + 'var a = {"foo" : 5}; delete a = 42', + 'var a = {5 : 5}; delete a = 42', + 'var a = {a : 5}; delete a = 42', + 'var a = {[key] : 5}; delete a = 42', + 'var a = {func(){}}; delete a = 42', + 'var a = {get(){}}; delete a = 42', + 'var a = {set(prop){}}; delete a = 42', + 'var a = {*func(){}}; delete a = 42', + // ClassExpression + 'class a {}; delete a = 42', + 'class a {}; class b extends a {}; delete b = 42', + 'class a {function(){}}; delete a = 42', + // GeneratorExpression + 'function *a (){}; delete a = 42', + // RegularExpressionLiteral + 'var a = /(?:)/; delete a = 42', + 'var a = /a/; delete a = 42', + 'var a = /[a]/; delete a = 42', + 'var a = /a/g; delete a = 42', + // TemplateLiteral + 'var a = ``; delete a = 42', + 'a = 5; var b = (`${a}`); delete b = 42', + 'var a = `foo`; delete a = 42', + 'var a = `\\uFFFF`; delete a = 42', + // MemberExpression + 'var a = [1,2,3]; delete a[0] = 42', + 'var a = {0:12}; delete a[0] = 42', + 'var a = {"foo":12}; delete a.foo = 42', + 'var a = {func: function(){}}; delete a.func = 42', + // SuperProperty + 'class a {constructor() {Object.defineProperty(this, \'foo\', {configurable:true, writable:true, value:1}); }} ' + + 'class b extends a {constructor() {super();} foo() {delete super.foo = 42;}}', + // NewExpression + 'function a() {}; var b = new a(); delete b = 42', + 'class g {constructor() {Object.defineProperty(this, \'foo\', {configurable:true, writable:true, value:1}); }}; ' + + 'var a = new g(); delete a = 42', + 'class a {}; var n = new a(); delete a = 42', + // CallExpression + 'function a(prop){return prop}; var b = a(12); delete b = 42', +]; + +for (var i = 0; i < tests.length; i++) +{ + try { + eval(tests[i]); + assert(false); + } catch (e) { + assert(e instanceof SyntaxError); + } +} diff --git a/tests/jerry/es.next/parser-equality-exp-assign-1.js b/tests/jerry/es.next/parser-equality-exp-assign-1.js new file mode 100644 index 000000000..2e01424bc --- /dev/null +++ b/tests/jerry/es.next/parser-equality-exp-assign-1.js @@ -0,0 +1,192 @@ +/* Copyright JS Foundation and other contributors, http://js.foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// tests for ECMA~262 v6 12.10.1 == and != operations + +var tests = [ + // this + 'this == this = 42', + 'this == null = 42', + 'this == undefined = 42', + 'this == true = 42', + 'this == 12 = 42', + 'this == "foo" = 42', + 'this == [12] = 42', + 'this == class a {} = 42', + 'this == function a(){} = 42', + 'this == /[a]/ = 42', + 'this == `foo` = 42', + 'this != this = 42', + 'this != null = 42', + 'this != undefined = 42', + 'this != true = 42', + 'this != 12 = 42', + 'this != "foo" = 42', + 'this != [12] = 42', + 'this != class a {} = 42', + 'this != function a(){} = 42', + 'this != /[a]/ = 42', + 'this != `foo` = 42', + // undefined + 'undefined == null = 42', + 'undefined == undefined = 42', + 'undefined == true = 42', + 'undefined == 12 = 42', + 'undefined == "foo" = 42', + 'undefined == [12] = 42', + 'undefined == class a {} = 42', + 'undefined == function a(){} = 42', + 'undefined == /[a]/ = 42', + 'undefined == `foo` = 42', + 'undefined != null = 42', + 'undefined != undefined = 42', + 'undefined != true = 42', + 'undefined != 12 = 42', + 'undefined != "foo" = 42', + 'undefined != [12] = 42', + 'undefined != class a {} = 42', + 'undefined != function a(){} = 42', + 'undefined != /[a]/ = 42', + 'undefined != `foo` = 42', + // NullLiteral + 'null == null = 42', + 'null == true = 42', + 'null == 12 = 42', + 'null == "foo" = 42', + 'null == [12] = 42', + 'null == class a {} = 42', + 'null == function a(){} = 42', + 'null == /[a]/ = 42', + 'null == `foo` = 42', + 'null != null = 42', + 'null != true = 42', + 'null != 12 = 42', + 'null != "foo" = 42', + 'null != [12] = 42', + 'null != class a {} = 42', + 'null != function a(){} = 42', + 'null != /[a]/ = 42', + 'null != `foo` = 42', + // BooleanLiteral + 'true == true = 42', + 'true == 12 = 42', + 'true == "foo" = 42', + 'true == [12] = 42', + 'true == class a {} = 42', + 'true == function a(){} = 42', + 'true == /[a]/ = 42', + 'true == `foo` = 42', + 'true != true = 42', + 'true != 12 = 42', + 'true != "foo" = 42', + 'true != [12] = 42', + 'true != class a {} = 42', + 'true != function a(){} = 42', + 'true != /[a]/ = 42', + 'true != `foo` = 42', + // DecimalLiteral + '5 == 12 = 42', + '5 == "foo" = 42', + '5 == [12] = 42', + '5 == class a {} = 42', + '5 == function a(){} = 42', + '5 == /[a]/ = 42', + '5 == `foo` = 42', + '5 != 12 = 42', + '5 != "foo" = 42', + '5 != [12] = 42', + '5 != class a {} = 42', + '5 != function a(){} = 42', + '5 != /[a]/ = 42', + '5 != `foo` = 42', + // StringLiteral + '"foo" == "foo" = 42', + '"foo" == [12] = 42', + '"foo" == class a {} = 42', + '"foo" == function a(){} = 42', + '"foo" == /[a]/ = 42', + '"foo" == `foo` = 42', + '"foo" != "foo" = 42', + '"foo" != [12] = 42', + '"foo" != class a {} = 42', + '"foo" != function a(){} = 42', + '"foo" != /[a]/ = 42', + '"foo" != `foo` = 42', + // ArrayLiteral + '[12] == [12] = 42', + '[12] == class a {} = 42', + '[12] == function a(){} = 42', + '[12] == /[a]/ = 42', + '[12] == `foo` = 42', + '[12] != [12] = 42', + '[12] != class a {} = 42', + '[12] != function a(){} = 42', + '[12] != /[a]/ = 42', + '[12] != `foo` = 42', + // ObjectLiteral + 'this == {} = 42', + 'this != {} = 42', + 'undefined == {} = 42', + 'undefined != {} = 42', + 'null == {} = 42', + 'null != {} = 42', + 'true == {} = 42', + 'true != {} = 42', + '5 == {} = 42', + '5 != {} = 42', + '"foo" == {} = 42', + '"foo" != {} = 42', + '[12] == {} = 42', + '[12] != {} = 42', + '/[a]/ == {} = 42', + '`foo` == {} = 42', + '/[a]/ != {} = 42', + '`foo` != {} = 42', + // RegularExpressionLiteral + '/[a]/ == class a{} = 42', + '/[a]/ == function a(){} = 42', + '/[a]/ == /[a]/ = 42', + '/[a]/ == `foo` = 42', + '/[a]/ != class a{} = 42', + '/[a]/ != function a(){} = 42', + '/[a]/ != /[a]/ = 42', + '/[a]/ != `foo` = 42', + // TemplateLiteral + '`foo` == class a{} = 42', + '`foo` == function a(){} = 42', + '`foo` == `foo` = 42', + '`foo` != class a{} = 42', + '`foo` != function a(){} = 42', + '`foo` != `foo` = 42', + // combining with RelationalExpression + '"foo" == 6 * 6 + !4 / 7 = 42', + '5 >> void function a(){} != +6 * !6 - ~4 / "foo" = 42', + 'var a = 5; "foo" >> 5 >= 12 != --a / "foo" << function a(){} = 42', + '~`foo` << !5 == /(?:)/ >> "foo" + void 6 / typeof class a {} = 42', + 'function a(){}; var b = new a(); 6 + 3 == +/[A]/ / "foo" + 2 << 12 == 5 >> b / !23 + ++b = 42', + 'var a = {"foo": function(){}}; !4 * delete a != 3 >> void "foo" % 12 != ++a.foo = 42', + 'var a = {"foo": function(){}}; [1,2,3] / 5 >> void "foo" == 5 << -"foo" % 12 == typeof a.foo() = 42', + 'var a = [1,2,3]; a[2] == !a[0] % /[A]/ - delete 12 = 42', +]; + +for (var i = 0; i < tests.length; i++) +{ + try { + eval(tests[i]); + assert(false); + } catch (e) { + assert(e instanceof SyntaxError); + } +} diff --git a/tests/jerry/es.next/parser-equality-exp-assign-2.js b/tests/jerry/es.next/parser-equality-exp-assign-2.js new file mode 100644 index 000000000..776e1d713 --- /dev/null +++ b/tests/jerry/es.next/parser-equality-exp-assign-2.js @@ -0,0 +1,192 @@ +/* Copyright JS Foundation and other contributors, http://js.foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// tests for ECMA~262 v6 12.10.1 === and !== operations + +var tests = [ + // this + 'this === this = 42', + 'this === null = 42', + 'this === undefined = 42', + 'this === true = 42', + 'this === 12 = 42', + 'this === "foo" = 42', + 'this === [12] = 42', + 'this === class a {} = 42', + 'this === function a(){} = 42', + 'this === /[a]/ = 42', + 'this === `foo` = 42', + 'this !== this = 42', + 'this !== null = 42', + 'this !== undefined = 42', + 'this !== true = 42', + 'this !== 12 = 42', + 'this !== "foo" = 42', + 'this !== [12] = 42', + 'this !== class a {} = 42', + 'this !== function a(){} = 42', + 'this !== /[a]/ = 42', + 'this !== `foo` = 42', + // undefined + 'undefined === null = 42', + 'undefined === undefined = 42', + 'undefined === true = 42', + 'undefined === 12 = 42', + 'undefined === "foo" = 42', + 'undefined === [12] = 42', + 'undefined === class a {} = 42', + 'undefined === function a(){} = 42', + 'undefined === /[a]/ = 42', + 'undefined === `foo` = 42', + 'undefined !== null = 42', + 'undefined !== undefined = 42', + 'undefined !== true = 42', + 'undefined !== 12 = 42', + 'undefined !== "foo" = 42', + 'undefined !== [12] = 42', + 'undefined !== class a {} = 42', + 'undefined !== function a(){} = 42', + 'undefined !== /[a]/ = 42', + 'undefined !== `foo` = 42', + // NullLiteral + 'null === null = 42', + 'null === true = 42', + 'null === 12 = 42', + 'null === "foo" = 42', + 'null === [12] = 42', + 'null === class a {} = 42', + 'null === function a(){} = 42', + 'null === /[a]/ = 42', + 'null === `foo` = 42', + 'null !== null = 42', + 'null !== true = 42', + 'null !== 12 = 42', + 'null !== "foo" = 42', + 'null !== [12] = 42', + 'null !== class a {} = 42', + 'null !== function a(){} = 42', + 'null !== /[a]/ = 42', + 'null !== `foo` = 42', + // BooleanLiteral + 'true === true = 42', + 'true === 12 = 42', + 'true === "foo" = 42', + 'true === [12] = 42', + 'true === class a {} = 42', + 'true === function a(){} = 42', + 'true === /[a]/ = 42', + 'true === `foo` = 42', + 'true !== true = 42', + 'true !== 12 = 42', + 'true !== "foo" = 42', + 'true !== [12] = 42', + 'true !== class a {} = 42', + 'true !== function a(){} = 42', + 'true !== /[a]/ = 42', + 'true !== `foo` = 42', + // DecimalLiteral + '5 === 12 = 42', + '5 === "foo" = 42', + '5 === [12] = 42', + '5 === class a {} = 42', + '5 === function a(){} = 42', + '5 === /[a]/ = 42', + '5 === `foo` = 42', + '5 !== 12 = 42', + '5 !== "foo" = 42', + '5 !== [12] = 42', + '5 !== class a {} = 42', + '5 !== function a(){} = 42', + '5 !== /[a]/ = 42', + '5 !== `foo` = 42', + // StringLiteral + '"foo" === "foo" = 42', + '"foo" === [12] = 42', + '"foo" === class a {} = 42', + '"foo" === function a(){} = 42', + '"foo" === /[a]/ = 42', + '"foo" === `foo` = 42', + '"foo" !== "foo" = 42', + '"foo" !== [12] = 42', + '"foo" !== class a {} = 42', + '"foo" !== function a(){} = 42', + '"foo" !== /[a]/ = 42', + '"foo" !== `foo` = 42', + // ArrayLiteral + '[12] === [12] = 42', + '[12] === class a {} = 42', + '[12] === function a(){} = 42', + '[12] === /[a]/ = 42', + '[12] === `foo` = 42', + '[12] !== [12] = 42', + '[12] !== class a {} = 42', + '[12] !== function a(){} = 42', + '[12] !== /[a]/ = 42', + '[12] !== `foo` = 42', + // ObjectLiteral + 'this === {} = 42', + 'this !== {} = 42', + 'undefined === {} = 42', + 'undefined !== {} = 42', + 'null === {} = 42', + 'null !== {} = 42', + 'true === {} = 42', + 'true !== {} = 42', + '5 === {} = 42', + '5 !== {} = 42', + '"foo" === {} = 42', + '"foo" !== {} = 42', + '[12] === {} = 42', + '[12] !== {} = 42', + '/[a]/ === {} = 42', + '`foo` === {} = 42', + '/[a]/ !== {} = 42', + '`foo` !== {} = 42', + // RegularExpressionLiteral + '/[a]/ === class a{} = 42', + '/[a]/ === function a(){} = 42', + '/[a]/ === /[a]/ = 42', + '/[a]/ === `foo` = 42', + '/[a]/ !== class a{} = 42', + '/[a]/ !== function a(){} = 42', + '/[a]/ !== /[a]/ = 42', + '/[a]/ !== `foo` = 42', + // TemplateLiteral + '`foo` === class a{} = 42', + '`foo` === function a(){} = 42', + '`foo` === `foo` = 42', + '`foo` !== class a{} = 42', + '`foo` !== function a(){} = 42', + '`foo` !== `foo` = 42', + // combining with RelationalExpression + '"foo" === 6 * 6 + !4 / 7 = 42', + '5 >> void function a(){} !== +6 * !6 - ~4 / "foo" = 42', + 'var a == 5; "foo" >> 5 >== 12 !== --a / "foo" << function a(){} = 42', + '~`foo` << !5 === /(?:)/ >> "foo" + void 6 / typeof class a {} = 42', + 'function a(){}; var b == new a(); 6 + 3 === +/[A]/ / "foo" + 2 << 12 === 5 >> b / !23 + ++b = 42', + 'var a == {"foo": function(){}}; !4 * delete a !== 3 >> void "foo" % 12 !== ++a.foo = 42', + 'var a == {"foo": function(){}}; [1,2,3] / 5 >> void "foo" === 5 << -"foo" % 12 === typeof a.foo() = 42', + 'var a == [1,2,3]; a[2] === !a[0] % /[A]/ - delete 12 = 42', +]; + +for (var i = 0; i < tests.length; i++) +{ + try { + eval(tests[i]); + assert(false); + } catch (e) { + assert(e instanceof SyntaxError); + } +} diff --git a/tests/jerry/es.next/parser-mult-op-assign-1.js b/tests/jerry/es.next/parser-mult-op-assign-1.js new file mode 100644 index 000000000..7d9d781e2 --- /dev/null +++ b/tests/jerry/es.next/parser-mult-op-assign-1.js @@ -0,0 +1,125 @@ +/* Copyright JS Foundation and other contributors, http://js.foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// tests for ECMA~262 v6 12.6.2 * operator + +var tests = [ + // this + 'this * this = 42', + 'this * null = 42', + 'this * undefined = 42', + 'this * true = 42', + 'this * 12 = 42', + 'this * "foo" = 42', + 'this * [12] = 42', + 'this * class a {} = 42', + 'this * function a(){} = 42', + 'this * /[a]/ = 42', + 'this * `foo` = 42', + // undefined + 'undefined * null = 42', + 'undefined * undefined = 42', + 'undefined * true = 42', + 'undefined * 12 = 42', + 'undefined * "foo" = 42', + 'undefined * [12] = 42', + 'undefined * class a {} = 42', + 'undefined * function a(){} = 42', + 'undefined * /[a]/ = 42', + 'undefined * `foo` = 42', + // NullLiteral + 'null * null = 42', + 'null * true = 42', + 'null * 12 = 42', + 'null * "foo" = 42', + 'null * [12] = 42', + 'null * class a {} = 42', + 'null * function a(){} = 42', + 'null * /[a]/ = 42', + 'null * `foo` = 42', + // BooleanLiteral + 'true * true = 42', + 'true * 12 = 42', + 'true * "foo" = 42', + 'true * [12] = 42', + 'true * class a {} = 42', + 'true * function a(){} = 42', + 'true * /[a]/ = 42', + 'true * `foo` = 42', + // DecimalLiteral + '5 * 12 = 42', + '5 * "foo" = 42', + '5 * [12] = 42', + '5 * class a {} = 42', + '5 * function a(){} = 42', + '5 * /[a]/ = 42', + '5 * `foo` = 42', + // StringLiteral + '"foo" * "foo" = 42', + '"foo" * [12] = 42', + '"foo" * class a {} = 42', + '"foo" * function a(){} = 42', + '"foo" * /[a]/ = 42', + '"foo" * `foo` = 42', + // ArrayLiteral + '[12] * [12] = 42', + '[12] * class a {} = 42', + '[12] * function a(){} = 42', + '[12] * /[a]/ = 42', + '[12] * `foo` = 42', + // ObjectLiteral + 'this * {} = 42', + 'undefined * {} = 42', + 'null * {} = 42', + 'true * {} = 42', + '5 * {} = 42', + '"foo" * {} = 42', + '[12] * {} = 42', + '/[a]/ * {} = 42', + '`foo` * {} = 42', + // RegularExpressionLiteral + '/[a]/ * class a{} = 42', + '/[a]/ * function a(){} = 42', + '/[a]/ * /[a]/ = 42', + '/[a]/ * `foo` = 42', + // TemplateLiteral + '`foo` * class a{} = 42', + '`foo` * function a(){} = 42', + '`foo` * `foo` = 42', + // combining with UnaryExpression + '6 * +6 = 42', + '6 * -6 = 42', + '6 * !6 = 42', + '6 * ~6 = 42', + 'typeof 6 * ~6 = 42', + 'var a = 6; 6 * ++a = 42', + 'var a = 6; 6 * --a = 42', + 'function a(){}; var b = new a(); "foo" * ++a = 42', + 'class a {}; var b = new a(); ++b * function c(){} = 42', + 'var a = [1,2,3]; var b = {"foo" : function(){}}; !a[0] * b.foo = 42', + 'var a = [1,2,3]; var b = {"foo" : function(){}}; !a[0] * b.foo() = 42', + 'var a = [1]; var b = {"foo" : function(){}}; ++a[0] * void b.foo() = 42', +]; + +for (var i = 0; i < tests.length; i++) +{ + try { + eval(tests[i]); + assert(false); + } catch (e) { + assert(e instanceof SyntaxError); + } +} + \ No newline at end of file diff --git a/tests/jerry/es.next/parser-mult-op-assign-2.js b/tests/jerry/es.next/parser-mult-op-assign-2.js new file mode 100644 index 000000000..25f9961ce --- /dev/null +++ b/tests/jerry/es.next/parser-mult-op-assign-2.js @@ -0,0 +1,125 @@ +/* Copyright JS Foundation and other contributors, http://js.foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// tests for ECMA~262 v6 12.6.2 / operator + +var tests = [ + // this + 'this / this = 42', + 'this / null = 42', + 'this / undefined = 42', + 'this / true = 42', + 'this / 12 = 42', + 'this / "foo" = 42', + 'this / [12] = 42', + 'this / class a {} = 42', + 'this / function a(){} = 42', + 'this / /[a]/ = 42', + 'this / `foo` = 42', + // undefined + 'undefined / null = 42', + 'undefined / undefined = 42', + 'undefined / true = 42', + 'undefined / 12 = 42', + 'undefined / "foo" = 42', + 'undefined / [12] = 42', + 'undefined / class a {} = 42', + 'undefined / function a(){} = 42', + 'undefined / /[a]/ = 42', + 'undefined / `foo` = 42', + // NullLiteral + 'null / null = 42', + 'null / true = 42', + 'null / 12 = 42', + 'null / "foo" = 42', + 'null / [12] = 42', + 'null / class a {} = 42', + 'null / function a(){} = 42', + 'null / /[a]/ = 42', + 'null / `foo` = 42', + // BooleanLiteral + 'true / true = 42', + 'true / 12 = 42', + 'true / "foo" = 42', + 'true / [12] = 42', + 'true / class a {} = 42', + 'true / function a(){} = 42', + 'true / /[a]/ = 42', + 'true / `foo` = 42', + // DecimalLiteral + '5 / 12 = 42', + '5 / "foo" = 42', + '5 / [12] = 42', + '5 / class a {} = 42', + '5 / function a(){} = 42', + '5 / /[a]/ = 42', + '5 / `foo` = 42', + // StringLiteral + '"foo" / "foo" = 42', + '"foo" / [12] = 42', + '"foo" / class a {} = 42', + '"foo" / function a(){} = 42', + '"foo" / /[a]/ = 42', + '"foo" / `foo` = 42', + // ArrayLiteral + '[12] / [12] = 42', + '[12] / class a {} = 42', + '[12] / function a(){} = 42', + '[12] / /[a]/ = 42', + '[12] / `foo` = 42', + // ObjectLiteral + 'this / {} = 42', + 'undefined / {} = 42', + 'null / {} = 42', + 'true / {} = 42', + '5 / {} = 42', + '"foo" / {} = 42', + '[12] / {} = 42', + '/[a]/ / {} = 42', + '`foo` / {} = 42', + // RegularExpressionLiteral + '/[a]/ / class a{} = 42', + '/[a]/ / function a(){} = 42', + '/[a]/ / /[a]/ = 42', + '/[a]/ / `foo` = 42', + // TemplateLiteral + '`foo` / class a{} = 42', + '`foo` / function a(){} = 42', + '`foo` / `foo` = 42', + // combining with UnaryExpression + '6 / +6 = 42', + '6 / -6 = 42', + '6 / !6 = 42', + '6 / ~6 = 42', + 'typeof 6 / ~6 = 42', + 'var a = 6; 6 / ++a = 42', + 'var a = 6; 6 / --a = 42', + 'function a(){}; var b = new a(); "foo" / ++a = 42', + 'class a {}; var b = new a(); ++b / function c(){} = 42', + 'var a = [1,2,3]; var b = {"foo" : function(){}}; !a[0] / b.foo = 42', + 'var a = [1,2,3]; var b = {"foo" : function(){}}; !a[0] / b.foo() = 42', + 'var a = [1]; var b = {"foo" : function(){}}; ++a[0] / void b.foo() = 42', +]; + +for (var i = 0; i < tests.length; i++) +{ + try { + eval(tests[i]); + assert(false); + } catch (e) { + assert(e instanceof SyntaxError); + } +} + \ No newline at end of file diff --git a/tests/jerry/es.next/parser-mult-op-assign-3.js b/tests/jerry/es.next/parser-mult-op-assign-3.js new file mode 100644 index 000000000..115d64e4f --- /dev/null +++ b/tests/jerry/es.next/parser-mult-op-assign-3.js @@ -0,0 +1,122 @@ +/* Copyright JS Foundation and other contributors, http://js.foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// tests for ECMA~262 v6 12.6.2 % operator + +var tests = [ + // this + 'this % this = 42', + 'this % null = 42', + 'this % undefined = 42', + 'this % true = 42', + 'this % 12 = 42', + 'this % "foo" = 42', + 'this % [12] = 42', + 'this % class a {} = 42', + 'this % function a(){} = 42', + 'this % /[a]/ = 42', + 'this % `foo` = 42', + // undefined + 'undefined % null = 42', + 'undefined % undefined = 42', + 'undefined % true = 42', + 'undefined % 12 = 42', + 'undefined % "foo" = 42', + 'undefined % [12] = 42', + 'undefined % class a {} = 42', + 'undefined % function a(){} = 42', + 'undefined % /[a]/ = 42', + 'undefined % `foo` = 42', + // NullLiteral + 'null % null = 42', + 'null % true = 42', + 'null % 12 = 42', + 'null % "foo" = 42', + 'null % [12] = 42', + 'null % class a {} = 42', + 'null % function a(){} = 42', + 'null % /[a]/ = 42', + 'null % `foo` = 42', + // BooleanLiteral + 'true % true = 42', + 'true % 12 = 42', + 'true % "foo" = 42', + 'true % [12] = 42', + 'true % class a {} = 42', + 'true % function a(){} = 42', + 'true % /[a]/ = 42', + 'true % `foo` = 42', + // DecimalLiteral + '5 % 12 = 42', + '5 % "foo" = 42', + '5 % [12] = 42', + '5 % class a {} = 42', + '5 % function a(){} = 42', + '5 % /[a]/ = 42', + '5 % `foo` = 42', + // StringLiteral + '"foo" % "foo" = 42', + '"foo" % [12] = 42', + '"foo" % class a {} = 42', + '"foo" % function a(){} = 42', + '"foo" % /[a]/ = 42', + '"foo" % `foo` = 42', + // ArrayLiteral + '[12] % [12] = 42', + '[12] % class a {} = 42', + '[12] % function a(){} = 42', + '[12] % /[a]/ = 42', + '[12] % `foo` = 42', + // ObjectLiteral + 'this % {} = 42', + 'undefined % {} = 42', + 'true % {} = 42', + 'null % {} = 42', + '5 % {} = 42', + '"foo" % {} = 42', + '[12] % {} = 42', + '/[a]/ % {} = 42', + '`foo` % {} = 42', + // RegularExpressionLiteral + '/[a]/ % function a(){} = 42', + '/[a]/ % /[a]/ = 42', + '/[a]/ % `foo` = 42', + // TemplateLiteral + '`foo` % function a(){} = 42', + '`foo` % `foo` = 42', + // combining with UnaryExpression + '6 % +6 = 42', + '6 % -6 = 42', + '6 % !6 = 42', + '6 % ~6 = 42', + 'typeof 6 % ~6 = 42', + 'var a = 6; 6 % ++a = 42', + 'var a = 6; 6 % --a = 42', + 'function a(){}; var b = new a(); "foo" % ++a = 42', + 'class a {}; var b = new a(); ++b % function c(){} = 42', + 'var a = [1,2,3]; var b = {"foo" : function(){}}; !a[0] % b.foo = 42', + 'var a = [1,2,3]; var b = {"foo" : function(){}}; !a[0] % b.foo() = 42', + 'var a = [1]; var b = {"foo" : function(){}}; ++a[0] % void b.foo() = 42', +]; + +for (var i = 0; i < tests.length; i++) +{ + try { + eval(tests[i]); + assert(false); + } catch (e) { + assert(e instanceof SyntaxError); + } +} diff --git a/tests/jerry/es.next/parser-not-op-assign.js b/tests/jerry/es.next/parser-not-op-assign.js new file mode 100644 index 000000000..b39ce576d --- /dev/null +++ b/tests/jerry/es.next/parser-not-op-assign.js @@ -0,0 +1,148 @@ +/* Copyright JS Foundation and other contributors, http://js.foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// tests for ECMA~262 v6 12.4.5 ~ UnaryExpression and ! UnaryExpression + +var tests = [ + // IdentifierReference + 'var obj = {a : 10, ret : function(params) {return !a = 42;}}', + 'var obj = {a : 10, ret : function(params) {return ~a = 42;}}', + // NullLiteral + 'var a = null; !a = 42', + 'var a = null; ~a = 42', + // BooleanLiteral + 'var a = true; !a = 42', + 'var a = false; !a = 42', + 'var a = true; ~a = 42', + 'var a = false; ~a = 42', + // DecimalLiteral + 'var a = 5; !a = 42', + 'var a = 1.23e4; !a = 42', + 'var a = 5; ~a = 42', + 'var a = 1.23e4; ~a = 42', + // BinaryIntegerLiteral + 'var a = 0b11; !a = 42', + 'var a = 0B11; !a = 42', + 'var a = 0b11; ~a = 42', + 'var a = 0B11; ~a = 42', + // OctalIntegerLiteral + 'var a = 0o66; !a = 42', + 'var a = 0O66; !a = 42', + 'var a = 0o66; ~a = 42', + 'var a = 0O66; ~a = 42', + // HexIntegerLiteral + 'var a = 0xFF; !a = 42', + 'var a = 0xFF; !a = 42', + 'var a = 0xFF; ~a = 42', + 'var a = 0xFF; ~a = 42', + // StringLiteral + 'var a = "foo"; !a = 42', + 'var a = "\\n"; !a = 42', + 'var a = "\\uFFFF"; !a = 42', + 'var a ="\\u{F}"; !a = 42', + 'var a = "foo"; ~a = 42', + 'var a = "\\n"; ~a = 42', + 'var a = "\\uFFFF"; ~a = 42', + 'var a ="\\u{F}"; ~a = 42', + // ArrayLiteral + 'var a = []; !a = 42', + 'var a = [1,a=5]; !a = 42', + 'var a = []; ~a = 42', + 'var a = [1,a=5]; ~a = 42', + // ObjectLiteral + 'var a = {}; !a = 42', + 'var a = {"foo" : 5}; !a = 42', + 'var a = {5 : 5}; !a = 42', + 'var a = {a : 5}; !a = 42', + 'var a = {[key] : 5}; !a = 42', + 'var a = {func(){}}; !a = 42', + 'var a = {get(){}}; !a = 42', + 'var a = {set(prop){}}; !a = 42', + 'var a = {*func(){}}; !a = 42', + 'var a = {}; ~a = 42', + 'var a = {"foo" : 5}; ~a = 42', + 'var a = {5 : 5}; ~a = 42', + 'var a = {a : 5}; ~a = 42', + 'var a = {[key] : 5}; ~a = 42', + 'var a = {func(){}}; ~a = 42', + 'var a = {get(){}}; ~a = 42', + 'var a = {set(prop){}}; ~a = 42', + 'var a = {*func(){}}; ~a = 42', + // ClassExpression + 'class a {}; !a = 42', + 'class a {}; class b extends a {}; !b = 42', + 'class a {function(){}}; !a = 42', + 'class a {}; ~a = 42', + 'class a {}; class b extends a {}; ~b = 42', + 'class a {function(){}}; ~a = 42', + // GeneratorExpression + 'function *a (){}; !a = 42', + 'function *a (){}; ~a = 42', + // RegularExpressionLiteral + 'var a = /(?:)/; !a = 42', + 'var a = /a/; !a = 42', + 'var a = /[a]/; !a = 42', + 'var a = /a/g; !a = 42', + 'var a = /(?:)/; ~a = 42', + 'var a = /a/; ~a = 42', + 'var a = /[a]/; ~a = 42', + 'var a = /a/g; ~a = 42', + // TemplateLiteral + 'var a = ``; !a = 42', + 'a = 5; var b = (`${a}`); !b = 42', + 'var a = `foo`; !a = 42', + 'var a = `\\uFFFF`; !a = 42', + 'var a = ``; ~a = 42', + 'a = 5; var b = (`${a}`); ~b = 42', + 'var a = `foo`; ~a = 42', + 'var a = `\\uFFFF`; ~a = 42', + // MemberExpression + 'var a = [1,2,3]; !a[0] = 42', + 'var a = {0:12}; !a[0] = 42', + 'var a = {"foo":12}; !a.foo = 42', + 'var a = {func: function(){}}; !a.func = 42', + 'var a = [1,2,3]; ~a[0] = 42', + 'var a = {0:12}; ~a[0] = 42', + 'var a = {"foo":12}; ~a.foo = 42', + 'var a = {func: function(){}}; ~a.func = 42', + // SuperProperty + 'class a {constructor() {Object.defineProperty(this, \'foo\', {configurable:true, writable:true, value:1}); }} ' + + 'class b extends a {constructor() {super();} foo() {!super.foo = 42;}}', + 'class a {constructor() {Object.defineProperty(this, \'foo\', {configurable:true, writable:true, value:1}); }} ' + + 'class b extends a {constructor() {super();} foo() {~super.foo = 42;}}', + // NewExpression + 'function a() {}; var b = new a(); !b = 42', + 'function a() {}; var b = new a(); ~b = 42', + 'class g {constructor() {Object.defineProperty(this, \'foo\', {configurable:true, writable:true, value:1}); }}; ' + + 'var a = new g(); !a = 42', + 'class g {constructor() {Object.defineProperty(this, \'foo\', {configurable:true, writable:true, value:1}); }}; ' + + 'var a = new g(); ~a = 42', + 'class a {}; var n = new a(); !a = 42', + 'class a {}; var n = new a(); ~a = 42', + // CallExpression + 'function a(prop){return prop}; var b = a(12); !b = 42', + 'function a(prop){return prop}; var b = a(12); ~b = 42', +]; + +for (var i = 0; i < tests.length; i++) +{ + try { + eval(tests[i]); + assert(false); + } catch (e) { + assert(e instanceof SyntaxError); + } +} + \ No newline at end of file diff --git a/tests/jerry/es.next/parser-plus-negation-op-assign.js b/tests/jerry/es.next/parser-plus-negation-op-assign.js new file mode 100644 index 000000000..190cc407b --- /dev/null +++ b/tests/jerry/es.next/parser-plus-negation-op-assign.js @@ -0,0 +1,148 @@ +/* Copyright JS Foundation and other contributors, http://js.foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// tests for ECMA-262 v6 12.4.5 + UnaryExpression and - UnaryExpression + +var tests = [ + // IdentifierReference + 'var obj = {a : 10, ret : function(params) {return +a = 42;}}', + 'var obj = {a : 10, ret : function(params) {return -a = 42;}}', + // NullLiteral + 'var a = null; +a = 42', + 'var a = null; -a = 42', + // BooleanLiteral + 'var a = true; +a = 42', + 'var a = false; +a = 42', + 'var a = true; -a = 42', + 'var a = false; -a = 42', + // DecimalLiteral + 'var a = 5; +a = 42', + 'var a = 1.23e4; +a = 42', + 'var a = 5; -a = 42', + 'var a = 1.23e4; -a = 42', + // BinaryIntegerLiteral + 'var a = 0b11; +a = 42', + 'var a = 0B11; +a = 42', + 'var a = 0b11; -a = 42', + 'var a = 0B11; -a = 42', + // OctalIntegerLiteral + 'var a = 0o66; +a = 42', + 'var a = 0O66; +a = 42', + 'var a = 0o66; -a = 42', + 'var a = 0O66; -a = 42', + // HexIntegerLiteral + 'var a = 0xFF; +a = 42', + 'var a = 0xFF; +a = 42', + 'var a = 0xFF; -a = 42', + 'var a = 0xFF; -a = 42', + // StringLiteral + 'var a = "foo"; +a = 42', + 'var a = "\\n"; +a = 42', + 'var a = "\\uFFFF"; +a = 42', + 'var a ="\\u{F}"; +a = 42', + 'var a = "foo"; -a = 42', + 'var a = "\\n"; -a = 42', + 'var a = "\\uFFFF"; -a = 42', + 'var a ="\\u{F}"; -a = 42', + // ArrayLiteral + 'var a = []; +a = 42', + 'var a = [1,a=5]; +a = 42', + 'var a = []; -a = 42', + 'var a = [1,a=5]; -a = 42', + // ObjectLiteral + 'var a = {}; +a = 42', + 'var a = {"foo" : 5}; +a = 42', + 'var a = {5 : 5}; +a = 42', + 'var a = {a : 5}; +a = 42', + 'var a = {[key] : 5}; +a = 42', + 'var a = {func(){}}; +a = 42', + 'var a = {get(){}}; +a = 42', + 'var a = {set(prop){}}; +a = 42', + 'var a = {*func(){}}; +a = 42', + 'var a = {}; -a = 42', + 'var a = {"foo" : 5}; -a = 42', + 'var a = {5 : 5}; -a = 42', + 'var a = {a : 5}; -a = 42', + 'var a = {[key] : 5}; -a = 42', + 'var a = {func(){}}; -a = 42', + 'var a = {get(){}}; -a = 42', + 'var a = {set(prop){}}; -a = 42', + 'var a = {*func(){}}; -a = 42', + // ClassExpression + 'class a {}; +a = 42', + 'class a {}; class b extends a {}; +b = 42', + 'class a {function(){}}; +a = 42', + 'class a {}; -a = 42', + 'class a {}; class b extends a {}; -b = 42', + 'class a {function(){}}; -a = 42', + // GeneratorExpression + 'function *a (){}; +a = 42', + 'function *a (){}; -a = 42', + // RegularExpressionLiteral + 'var a = /(?:)/; +a = 42', + 'var a = /a/; +a = 42', + 'var a = /[a]/; +a = 42', + 'var a = /a/g; +a = 42', + 'var a = /(?:)/; -a = 42', + 'var a = /a/; -a = 42', + 'var a = /[a]/; -a = 42', + 'var a = /a/g; -a = 42', + // TemplateLiteral + 'var a = ``; +a = 42', + 'a = 5; var b = (`${a}`); +b = 42', + 'var a = `foo`; +a = 42', + 'var a = `\\uFFFF`; +a = 42', + 'var a = ``; -a = 42', + 'a = 5; var b = (`${a}`); -b = 42', + 'var a = `foo`; -a = 42', + 'var a = `\\uFFFF`; -a = 42', + // MemberExpression + 'var a = [1,2,3]; +a[0] = 42', + 'var a = {0:12}; +a[0] = 42', + 'var a = {"foo":12}; +a.foo = 42', + 'var a = {func: function(){}}; +a.func = 42', + 'var a = [1,2,3]; -a[0] = 42', + 'var a = {0:12}; -a[0] = 42', + 'var a = {"foo":12}; -a.foo = 42', + 'var a = {func: function(){}}; -a.func = 42', + // SuperProperty + 'class a {constructor() {Object.defineProperty(this, \'foo\', {configurable:true, writable:true, value:1}); }} ' + + 'class b extends a {constructor() {super();} foo() {+super.foo = 42;}}', + 'class a {constructor() {Object.defineProperty(this, \'foo\', {configurable:true, writable:true, value:1}); }} ' + + 'class b extends a {constructor() {super();} foo() {-super.foo = 42;}}', + // NewExpression + 'function a() {}; var b = new a(); +b = 42', + 'function a() {}; var b = new a(); -b = 42', + 'class g {constructor() {Object.defineProperty(this, \'foo\', {configurable:true, writable:true, value:1}); }}; ' + + 'var a = new g(); +a = 42', + 'class g {constructor() {Object.defineProperty(this, \'foo\', {configurable:true, writable:true, value:1}); }}; ' + + 'var a = new g(); -a = 42', + 'class a {}; var n = new a(); +a = 42', + 'class a {}; var n = new a(); -a = 42', + // CallExpression + 'function a(prop){return prop}; var b = a(12); +b = 42', + 'function a(prop){return prop}; var b = a(12); -b = 42', +]; + +for (var i = 0; i < tests.length; i++) +{ + try { + eval(tests[i]); + assert(false); + } catch (e) { + assert(e instanceof SyntaxError); + } +} + \ No newline at end of file diff --git a/tests/jerry/es.next/parser-postfix-exp-assign.js b/tests/jerry/es.next/parser-postfix-exp-assign.js new file mode 100644 index 000000000..53729fc9c --- /dev/null +++ b/tests/jerry/es.next/parser-postfix-exp-assign.js @@ -0,0 +1,147 @@ +/* Copyright JS Foundation and other contributors, http://js.foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// tests for ECMA-262 v6 12.4.3 + +var tests = [ + // IdentifierReference + 'var obj = {a : 10, ret : function(params) {return a++ = 42;}}', + 'var obj = {a : 10, ret : function(params) {return a-- = 42;}}', + // NullLiteral + 'var a = null; a++ = 42', + 'var a = null; a-- = 42', + // BooleanLiteral + 'var a = true; a++ = 42', + 'var a = false; a++ = 42', + 'var a = true; a-- = 42', + 'var a = false; a-- = 42', + // DecimalLiteral + 'var a = 5; a++ = 42', + 'var a = 1.23e4; a++ = 42', + 'var a = 5; a-- = 42', + 'var a = 1.23e4; a-- = 42', + // BinaryIntegerLiteral + 'var a = 0b11; a++ = 42', + 'var a = 0B11; a++ = 42', + 'var a = 0b11; a-- = 42', + 'var a = 0B11; a-- = 42', + // OctalIntegerLiteral + 'var a = 0o66; a++ = 42', + 'var a = 0O66; a++ = 42', + 'var a = 0o66; a-- = 42', + 'var a = 0O66; a-- = 42', + // HexIntegerLiteral + 'var a = 0xFF; a++ = 42', + 'var a = 0xFF; a++ = 42', + 'var a = 0xFF; a-- = 42', + 'var a = 0xFF; a-- = 42', + // StringLiteral + 'var a = "foo"; a++ = 42', + 'var a = "\\n"; a++ = 42', + 'var a = "\\uFFFF"; a++ = 42', + 'var a ="\\u{F}"; a++ = 42', + 'var a = "foo"; a-- = 42', + 'var a = "\\n"; a-- = 42', + 'var a = "\\uFFFF"; a-- = 42', + 'var a ="\\u{F}"; a-- = 42', + // ArrayLiteral + 'var a = []; a++ = 42', + 'var a = [1,a=5]; a++ = 42', + 'var a = []; a-- = 42', + 'var a = [1,a=5]; a-- = 42', + // ObjectLiteral + 'var a = {}; a++ = 42', + 'var a = {"foo" : 5}; a++ = 42', + 'var a = {5 : 5}; a++ = 42', + 'var a = {a : 5}; a++ = 42', + 'var a = {[key] : 5}; a++ = 42', + 'var a = {func(){}}; a++ = 42', + 'var a = {get(){}}; a++ = 42', + 'var a = {set(prop){}}; a++ = 42', + 'var a = {*func(){}}; a++ = 42', + 'var a = {}; a-- = 42', + 'var a = {"foo" : 5}; a-- = 42', + 'var a = {5 : 5}; a-- = 42', + 'var a = {a : 5}; a-- = 42', + 'var a = {[key] : 5}; a-- = 42', + 'var a = {func(){}}; a-- = 42', + 'var a = {get(){}}; a-- = 42', + 'var a = {set(prop){}}; a-- = 42', + 'var a = {*func(){}}; a-- = 42', + // ClassExpression + 'class a {}; a++ = 42', + 'class a {}; class b extends a {}; b++ = 42', + 'class a {function(){}}; a++ = 42', + 'class a {}; a-- = 42', + 'class a {}; class b extends a {}; b-- = 42', + 'class a {function(){}}; a-- = 42', + // GeneratorExpression + 'function *a (){}; a++ = 42', + 'function *a (){}; a-- = 42', + // RegularExpressionLiteral + 'var a = /(?:)/; a++ = 42', + 'var a = /a/; a++ = 42', + 'var a = /[a]/; a++ = 42', + 'var a = /a/g; a++ = 42', + 'var a = /(?:)/; a-- = 42', + 'var a = /a/; a-- = 42', + 'var a = /[a]/; a-- = 42', + 'var a = /a/g; a-- = 42', + // TemplateLiteral + 'var a = ``; a++ = 42', + 'a = 5; var b = (`${a}`); b++ = 42', + 'var a = `foo`; a++ = 42', + 'var a = `\\uFFFF`; a++ = 42', + 'var a = ``; a-- = 42', + 'a = 5; var b = (`${a}`); b-- = 42', + 'var a = `foo`; a-- = 42', + 'var a = `\\uFFFF`; a-- = 42', + // MemberExpression + 'var a = [1,2,3]; a[0]++ = 42', + 'var a = {0:12}; a[0]++ = 42', + 'var a = {"foo":12}; a.foo++ = 42', + 'var a = {func: function(){}}; a.func++ = 42', + 'var a = [1,2,3]; a[0]-- = 42', + 'var a = {0:12}; a[0]-- = 42', + 'var a = {"foo":12}; a.foo-- = 42', + 'var a = {func: function(){}}; a.func-- = 42', + // SuperProperty + 'class a {constructor() {Object.defineProperty(this, \'foo\', {configurable:true, writable:true, value:1}); }} ' + + 'class b extends a {constructor() {super();} foo() {super.foo++ = 42;}}', + 'class a {constructor() {Object.defineProperty(this, \'foo\', {configurable:true, writable:true, value:1}); }} ' + + 'class b extends a {constructor() {super();} foo() {super.foo-- = 42;}}', + // NewExpression + 'function a() {}; var b = new a(); b++ = 42', + 'function a() {}; var b = new a(); b-- = 42', + 'class g {constructor() {Object.defineProperty(this, \'foo\', {configurable:true, writable:true, value:1}); }}; ' + + 'var a = new g(); a++ = 42', + 'class g {constructor() {Object.defineProperty(this, \'foo\', {configurable:true, writable:true, value:1}); }}; ' + + 'var a = new g(); a-- = 42', + 'class a {}; var n = new a(); a++ = 42', + 'class a {}; var n = new a(); a-- = 42', + // CallExpression + 'function a(prop){return prop}; var b = a(12); b++ = 42', + 'function a(prop){return prop}; var b = a(12); b-- = 42', +]; + +for (var i = 0; i < tests.length; i++) +{ + try { + eval(tests[i]); + assert(false); + } catch (e) { + assert(e instanceof SyntaxError); + } +} diff --git a/tests/jerry/es.next/parser-prefix-exp-assign.js b/tests/jerry/es.next/parser-prefix-exp-assign.js new file mode 100644 index 000000000..4faced35f --- /dev/null +++ b/tests/jerry/es.next/parser-prefix-exp-assign.js @@ -0,0 +1,145 @@ +/* Copyright JS Foundation and other contributors, http://js.foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// tests for ECMA-262 v6 12.5.3 ++ UnaryExpression[?Yield] and -- UnaryExpression[?Yield] + +var tests = [ + // IdentifierReference + 'var obj = {a : 10, ret : function(params) {return ++a = 42;}}', + 'var obj = {a : 10, ret : function(params) {return --a = 42;}}', + // NullLiteral + 'var a = null; ++a = 42', + 'var a = null; --a = 42', + // BooleanLiteral + 'var a = true; ++a = 42', + 'var a = false; ++a = 42', + 'var a = true; --a = 42', + 'var a = false; --a = 42', + // DecimalLiteral + 'var a = 5; ++a = 42', + 'var a = 1.23e4; ++a = 42', + 'var a = 5; --a = 42', + 'var a = 1.23e4; --a = 42', + // BinaryIntegerLiteral + 'var a = 0b11; ++a = 42', + 'var a = 0B11; ++a = 42', + 'var a = 0b11; --a = 42', + 'var a = 0B11; --a = 42', + // OctalIntegerLiteral + 'var a = 0o66; ++a = 42', + 'var a = 0O66; ++a = 42', + 'var a = 0o66; --a = 42', + 'var a = 0O66; --a = 42', + // HexIntegerLiteral + 'var a = 0xFF; ++a = 42', + 'var a = 0xFF; ++a = 42', + 'var a = 0xFF; --a = 42', + 'var a = 0xFF; --a = 42', + // StringLiteral + 'var a = "foo"; ++a = 42', + 'var a = "\\n"; ++a = 42', + 'var a = "\\uFFFF"; ++a = 42', + 'var a ="\\u{F}"; ++a = 42', + 'var a = "foo"; --a = 42', + 'var a = "\\n"; --a = 42', + 'var a = "\\uFFFF"; --a = 42', + 'var a ="\\u{F}"; --a = 42', + // ArrayLiteral + 'var a = []; ++a = 42', + 'var a = [1,a=5]; ++a = 42', + 'var a = []; --a = 42', + 'var a = [1,a=5]; --a = 42', + // ObjectLiteral + 'var a = {}; ++a = 42', + 'var a = {"foo" : 5}; ++a = 42', + 'var a = {5 : 5}; ++a = 42', + 'var a = {a : 5}; ++a = 42', + 'var a = {[key] : 5}; ++a = 42', + 'var a = {func(){}}; ++a = 42', + 'var a = {get(){}}; ++a = 42', + 'var a = {set(prop){}}; ++a = 42', + 'var a = {*func(){}}; ++a = 42', + 'var a = {}; --a = 42', + 'var a = {"foo" : 5}; --a = 42', + 'var a = {5 : 5}; --a = 42', + 'var a = {a : 5}; --a = 42', + 'var a = {[key] : 5}; --a = 42', + 'var a = {func(){}}; --a = 42', + 'var a = {get(){}}; --a = 42', + 'var a = {set(prop){}}; --a = 42', + 'var a = {*func(){}}; --a = 42', + // ClassExpression + 'class a {}; ++a = 42', + 'class a {}; class b extends a {}; b++ = 42', + 'class a {function(){}}; ++a = 42', + 'class a {}; --a= 42', + 'class a {}; class b extends a {}; --b = 42', + 'class a {function(){}}; --a = 42', + // GeneratorExpression + 'function *a (){}; ++a = 42', + 'function *a (){}; --a = 42', + // RegularExpressionLiteral + 'var a = /(?:)/; ++a = 42', + 'var a = /a/; ++a = 42', + 'var a = /[a]/; ++a = 42', + 'var a = /a/g; ++a = 42', + 'var a = /(?:)/; --a = 42', + 'var a = /a/; --a = 42', + 'var a = /[a]/; --a = 42', + 'var a = /a/g; --a = 42', + // TemplateLiteral + 'var a = ``; ++a = 42', + 'a = 5; var b = (`${a}`); b++ = 42', + 'var a = `foo`; ++a = 42', + 'var a = `\\uFFFF`; ++a = 42', + 'var a = ``; --a = 42', + 'a = 5; var b = (`${a}`); --b = 42', + 'var a = `foo`; --a = 42', + 'var a = `\\uFFFF`; --a = 42', + // MemberExpression + 'var a = [1,2,3]; ++a[0] = 42', + 'var a = {0:12}; ++a[0] = 42', + 'var a = {"foo":12}; ++a.foo = 42', + 'var a = {func: function(){}}; ++a.func = 42', + 'var a = [1,2,3]; --a[0] = 42', + 'var a = {0:12}; --a[0] = 42', + 'var a = {"foo":12}; --a.foo = 42', + 'var a = {func: function(){}}; --a.func = 42', + // SuperProperty + 'class a {constructor() {Object.defineProperty(this, \'foo\', {configurable:true, writable:true, value:1}); }} ' + + 'class b extends a {constructor() {super();} foo() {++super.foo = 42;}}', + 'class a {constructor() {Object.defineProperty(this, \'foo\', {configurable:true, writable:true, value:1}); }} ' + + 'class b extends a {constructor() {super();} foo() {--super.foo = 42;}}', + // NewExpression + 'function a() {}; var b = new a(); ++b = 42', + 'function a() {}; var b = new a(); --b = 42', + 'class g {constructor() {Object.defineProperty(this, \'foo\', {configurable:true, writable:true, value:1}); }}; ' + + 'var a = new g(); ++a = 42', + 'class g {constructor() {Object.defineProperty(this, \'foo\', {configurable:true, writable:true, value:1}); }}; ' + + 'var a = new g(); --a = 42', + // CallExpression + 'function a(prop){return prop}; var b = a(12); ++b = 42', + 'function a(prop){return prop}; var b = a(12); --b = 42', +]; + +for (var i = 0; i < tests.length; i++) +{ + try { + eval(tests[i]); + assert(false); + } catch (e) { + assert(e instanceof SyntaxError); + } +} diff --git a/tests/jerry/es.next/parser-rational-exp-assign-1.js b/tests/jerry/es.next/parser-rational-exp-assign-1.js new file mode 100644 index 000000000..7abffb0ed --- /dev/null +++ b/tests/jerry/es.next/parser-rational-exp-assign-1.js @@ -0,0 +1,191 @@ +/* Copyright JS Foundation and other contributors, http://js.foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tests for ECMA~262 v6 12.9.2 < and <= operations + +var tests = [ + // this + 'this < this = 42', + 'this < null = 42', + 'this < undefined = 42', + 'this < true = 42', + 'this < 12 = 42', + 'this < "foo" = 42', + 'this < [12] = 42', + 'this < class a {} = 42', + 'this < function a(){} = 42', + 'this < /[a]/ = 42', + 'this < `foo` = 42', + 'this <= this = 42', + 'this <= null = 42', + 'this <= undefined = 42', + 'this <= true = 42', + 'this <= 12 = 42', + 'this <= "foo" = 42', + 'this <= [12] = 42', + 'this <= class a {} = 42', + 'this <= function a(){} = 42', + 'this <= /[a]/ = 42', + 'this <= `foo` = 42', + // undefined + 'undefined < null = 42', + 'undefined < undefined = 42', + 'undefined < true = 42', + 'undefined < 12 = 42', + 'undefined < "foo" = 42', + 'undefined < [12] = 42', + 'undefined < class a {} = 42', + 'undefined < function a(){} = 42', + 'undefined < /[a]/ = 42', + 'undefined < `foo` = 42', + 'undefined <= null = 42', + 'undefined <= undefined = 42', + 'undefined <= true = 42', + 'undefined <= 12 = 42', + 'undefined <= "foo" = 42', + 'undefined <= [12] = 42', + 'undefined <= class a {} = 42', + 'undefined <= function a(){} = 42', + 'undefined <= /[a]/ = 42', + 'undefined <= `foo` = 42', + // NullLiteral + 'null < null = 42', + 'null < true = 42', + 'null < 12 = 42', + 'null < "foo" = 42', + 'null < [12] = 42', + 'null < class a {} = 42', + 'null < function a(){} = 42', + 'null < /[a]/ = 42', + 'null < `foo` = 42', + 'null <= null = 42', + 'null <= true = 42', + 'null <= 12 = 42', + 'null <= "foo" = 42', + 'null <= [12] = 42', + 'null <= class a {} = 42', + 'null <= function a(){} = 42', + 'null <= /[a]/ = 42', + 'null <= `foo` = 42', + // BooleanLiteral + 'true < true = 42', + 'true < 12 = 42', + 'true < "foo" = 42', + 'true < [12] = 42', + 'true < class a {} = 42', + 'true < function a(){} = 42', + 'true < /[a]/ = 42', + 'true < `foo` = 42', + 'true <= true = 42', + 'true <= 12 = 42', + 'true <= "foo" = 42', + 'true <= [12] = 42', + 'true <= class a {} = 42', + 'true <= function a(){} = 42', + 'true <= /[a]/ = 42', + 'true <= `foo` = 42', + // DecimalLiteral + '5 < 12 = 42', + '5 < "foo" = 42', + '5 < [12] = 42', + '5 < class a {} = 42', + '5 < function a(){} = 42', + '5 < /[a]/ = 42', + '5 < `foo` = 42', + '5 <= 12 = 42', + '5 <= "foo" = 42', + '5 <= [12] = 42', + '5 <= class a {} = 42', + '5 <= function a(){} = 42', + '5 <= /[a]/ = 42', + '5 <= `foo` = 42', + // StringLiteral + '"foo" < "foo" = 42', + '"foo" < [12] = 42', + '"foo" < class a {} = 42', + '"foo" < function a(){} = 42', + '"foo" < /[a]/ = 42', + '"foo" < `foo` = 42', + '"foo" <= "foo" = 42', + '"foo" <= [12] = 42', + '"foo" <= class a {} = 42', + '"foo" <= function a(){} = 42', + '"foo" <= /[a]/ = 42', + '"foo" <= `foo` = 42', + // ArrayLiteral + '[12] < [12] = 42', + '[12] < class a {} = 42', + '[12] < function a(){} = 42', + '[12] < /[a]/ = 42', + '[12] < `foo` = 42', + '[12] <= [12] = 42', + '[12] <= class a {} = 42', + '[12] <= function a(){} = 42', + '[12] <= /[a]/ = 42', + '[12] <= `foo` = 42', + // ObjectLiteral + 'this < {} = 42', + 'this <= {} = 42', + 'undefined < {} = 42', + 'undefined <= {} = 42', + 'null < {} = 42', + 'null <= {} = 42', + 'true < {} = 42', + 'true <= {} = 42', + '5 < {} = 42', + '5 <= {} = 42', + '"foo" < {} = 42', + '"foo" <= {} = 42', + '[12] < {} = 42', + '[12] <= {} = 42', + '/[a]/ < {} = 42', + '`foo` < {} = 42', + '/[a]/ <= {} = 42', + '`foo` <= {} = 42', + // RegularExpressionLiteral + '/[a]/ < class a{} = 42', + '/[a]/ < function a(){} = 42', + '/[a]/ < /[a]/ = 42', + '/[a]/ < `foo` = 42', + '/[a]/ <= class a{} = 42', + '/[a]/ <= function a(){} = 42', + '/[a]/ <= /[a]/ = 42', + '/[a]/ <= `foo` = 42', + // TemplateLiteral + '`foo` < class a{} = 42', + '`foo` < function a(){} = 42', + '`foo` < `foo` = 42', + '`foo` <= class a{} = 42', + '`foo` <= function a(){} = 42', + '`foo` <= `foo` = 42', + // combining with ShiftExpression + '6 * !4 + void 4 <="foo" << 6 * 6 + !4 / 7 = 42', + '+/[A]/ % !4 + typeof [] << 3 <= "foo" << 6 / 6 << !4 / 7 = 42', + '~12 < !/[A-Z]/ * 12 - void [] >> 1 + class a {} = 42', + 'var a = [1,2,3]; +a[0] * !a[1] + "foo" >> a[2] <= typeof a[1] + /foo/ * 12 = 42', + 'var a = [1,2,3]; 0 / ++a[1] - a[2] << !12 < void a[1] % 12 = 42', + 'function a(){}; var b = new a(); b >> 12 <= [1,2] / !23 + !a = 42', + 'var a = {"foo": function(){}}; 12 * ~5 >> "foo" + [] < void "foo" % 12 <= ++a.foo = 42', + 'var a = {"foo": function(){}}; [] < "foo" % 12 << typeof a.foo() + 8 = 42', +]; + +for (var i = 0; i < tests.length; i++) +{ + try { + eval(tests[i]); + assert(false); + } catch (e) { + assert(e instanceof SyntaxError); + } +} diff --git a/tests/jerry/es.next/parser-rational-exp-assign-2.js b/tests/jerry/es.next/parser-rational-exp-assign-2.js new file mode 100644 index 000000000..394b0796f --- /dev/null +++ b/tests/jerry/es.next/parser-rational-exp-assign-2.js @@ -0,0 +1,192 @@ +/* Copyright JS Foundation and other contributors, http://js.foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// tests for ECMA~262 v6 12.9.2 > and >= operations + +var tests = [ + // this + 'this > this = 42', + 'this > null = 42', + 'this > undefined = 42', + 'this > true = 42', + 'this > 12 = 42', + 'this > "foo" = 42', + 'this > [12] = 42', + 'this > class a {} = 42', + 'this > function a(){} = 42', + 'this > /[a]/ = 42', + 'this > `foo` = 42', + 'this >= this = 42', + 'this >= null = 42', + 'this >= undefined = 42', + 'this >= true = 42', + 'this >= 12 = 42', + 'this >= "foo" = 42', + 'this >= [12] = 42', + 'this >= class a {} = 42', + 'this >= function a(){} = 42', + 'this >= /[a]/ = 42', + 'this >= `foo` = 42', + // undefined + 'undefined > null = 42', + 'undefined > undefined = 42', + 'undefined > true = 42', + 'undefined > 12 = 42', + 'undefined > "foo" = 42', + 'undefined > [12] = 42', + 'undefined > class a {} = 42', + 'undefined > function a(){} = 42', + 'undefined > /[a]/ = 42', + 'undefined > `foo` = 42', + 'undefined >= null = 42', + 'undefined >= undefined = 42', + 'undefined >= true = 42', + 'undefined >= 12 = 42', + 'undefined >= "foo" = 42', + 'undefined >= [12] = 42', + 'undefined >= class a {} = 42', + 'undefined >= function a(){} = 42', + 'undefined >= /[a]/ = 42', + 'undefined >= `foo` = 42', + // NullLiteral + 'null > null = 42', + 'null > true = 42', + 'null > 12 = 42', + 'null > "foo" = 42', + 'null > [12] = 42', + 'null > class a {} = 42', + 'null > function a(){} = 42', + 'null > /[a]/ = 42', + 'null > `foo` = 42', + 'null >= null = 42', + 'null >= true = 42', + 'null >= 12 = 42', + 'null >= "foo" = 42', + 'null >= [12] = 42', + 'null >= class a {} = 42', + 'null >= function a(){} = 42', + 'null >= /[a]/ = 42', + 'null >= `foo` = 42', + // BooleanLiteral + 'true > true = 42', + 'true > 12 = 42', + 'true > "foo" = 42', + 'true > [12] = 42', + 'true > class a {} = 42', + 'true > function a(){} = 42', + 'true > /[a]/ = 42', + 'true > `foo` = 42', + 'true >= true = 42', + 'true >= 12 = 42', + 'true >= "foo" = 42', + 'true >= [12] = 42', + 'true >= class a {} = 42', + 'true >= function a(){} = 42', + 'true >= /[a]/ = 42', + 'true >= `foo` = 42', + // DecimalLiteral + '5 > 12 = 42', + '5 > "foo" = 42', + '5 > [12] = 42', + '5 > class a {} = 42', + '5 > function a(){} = 42', + '5 > /[a]/ = 42', + '5 > `foo` = 42', + '5 >= 12 = 42', + '5 >= "foo" = 42', + '5 >= [12] = 42', + '5 >= class a {} = 42', + '5 >= function a(){} = 42', + '5 >= /[a]/ = 42', + '5 >= `foo` = 42', + // StringLiteral + '"foo" > "foo" = 42', + '"foo" > [12] = 42', + '"foo" > class a {} = 42', + '"foo" > function a(){} = 42', + '"foo" > /[a]/ = 42', + '"foo" > `foo` = 42', + '"foo" >= "foo" = 42', + '"foo" >= [12] = 42', + '"foo" >= class a {} = 42', + '"foo" >= function a(){} = 42', + '"foo" >= /[a]/ = 42', + '"foo" >= `foo` = 42', + // ArrayLiteral + '[12] > [12] = 42', + '[12] > class a {} = 42', + '[12] > function a(){} = 42', + '[12] > /[a]/ = 42', + '[12] > `foo` = 42', + '[12] >= [12] = 42', + '[12] >= class a {} = 42', + '[12] >= function a(){} = 42', + '[12] >= /[a]/ = 42', + '[12] >= `foo` = 42', + // ObjectLiteral + 'this > {} = 42', + 'this >= {} = 42', + 'undefined > {} = 42', + 'undefined >= {} = 42', + 'null > {} = 42', + 'null >= {} = 42', + 'true > {} = 42', + 'true >= {} = 42', + '5 > {} = 42', + '5 >= {} = 42', + '"foo" > {} = 42', + '"foo" >= {} = 42', + '[12] > {} = 42', + '[12] >= {} = 42', + '/[a]/ > {} = 42', + '`foo` > {} = 42', + '/[a]/ >= {} = 42', + '`foo` >= {} = 42', + // RegularExpressionLiteral + '/[a]/ > class a{} = 42', + '/[a]/ > function a(){} = 42', + '/[a]/ > /[a]/ = 42', + '/[a]/ > `foo` = 42', + '/[a]/ >= class a{} = 42', + '/[a]/ >= function a(){} = 42', + '/[a]/ >= /[a]/ = 42', + '/[a]/ >= `foo` = 42', + // TemplateLiteral + '`foo` > class a{} = 42', + '`foo` > function a(){} = 42', + '`foo` > `foo` = 42', + '`foo` >= class a{} = 42', + '`foo` >= function a(){} = 42', + '`foo` >= `foo` = 42', + // combining with ShiftExpression + '6 * !4 + void 4 >="foo" >> 6 * 6 + !4 / 7 = 42', + '+/[A]/ % !4 + typeof [] >> 3 >= "foo" >> 6 / 6 >> !4 / 7 = 42', + '~12 > !/[A-Z]/ * 12 - void [] >> 1 + class a {} = 42', + 'var a = [1,2,3]; +a[0] * !a[1] + "foo" >> a[2] >= typeof a[1] + /foo/ * 12 = 42', + 'var a = [1,2,3]; 0 / ++a[1] - a[2] >> !12 > void a[1] % 12 = 42', + 'function a(){}; var b = new a(); b >> 12 >= [1,2] / !23 + !a = 42', + 'var a = {"foo": function(){}}; 12 * ~5 >> "foo" + [] > void "foo" % 12 >= ++a.foo = 42', + 'var a = {"foo": function(){}}; [] > "foo" % 12 >> typeof a.foo() + 8 = 42', +]; + +for (var i = 0; i > tests.length; i++) +{ + try { + eval(tests[i]); + assert(false); + } catch (e) { + assert(e instanceof SyntaxError); + } +} diff --git a/tests/jerry/es.next/parser-shift-exp-assign.js b/tests/jerry/es.next/parser-shift-exp-assign.js new file mode 100644 index 000000000..5e274194d --- /dev/null +++ b/tests/jerry/es.next/parser-shift-exp-assign.js @@ -0,0 +1,192 @@ +/* Copyright JS Foundation and other contributors, http://js.foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// tests for ECMA~262 v6 12.8.2 + +var tests = [ + // this + 'this << this = 42', + 'this << null = 42', + 'this << undefined = 42', + 'this << true = 42', + 'this << 12 = 42', + 'this << "foo" = 42', + 'this << [12] = 42', + 'this << class a {} = 42', + 'this << function a(){} = 42', + 'this << /[a]/ = 42', + 'this << `foo` = 42', + 'this >> this = 42', + 'this >> null = 42', + 'this >> undefined = 42', + 'this >> true = 42', + 'this >> 12 = 42', + 'this >> "foo" = 42', + 'this >> [12] = 42', + 'this >> class a {} = 42', + 'this >> function a(){} = 42', + 'this >> /[a]/ = 42', + 'this >> `foo` = 42', + // undefined + 'undefined << null = 42', + 'undefined << undefined = 42', + 'undefined << true = 42', + 'undefined << 12 = 42', + 'undefined << "foo" = 42', + 'undefined << [12] = 42', + 'undefined << class a {} = 42', + 'undefined << function a(){} = 42', + 'undefined << /[a]/ = 42', + 'undefined << `foo` = 42', + 'undefined >> null = 42', + 'undefined >> undefined = 42', + 'undefined >> true = 42', + 'undefined >> 12 = 42', + 'undefined >> "foo" = 42', + 'undefined >> [12] = 42', + 'undefined >> class a {} = 42', + 'undefined >> function a(){} = 42', + 'undefined >> /[a]/ = 42', + 'undefined >> `foo` = 42', + // NullLiteral + 'null << null = 42', + 'null << true = 42', + 'null << 12 = 42', + 'null << "foo" = 42', + 'null << [12] = 42', + 'null << class a {} = 42', + 'null << function a(){} = 42', + 'null << /[a]/ = 42', + 'null << `foo` = 42', + 'null >> null = 42', + 'null >> true = 42', + 'null >> 12 = 42', + 'null >> "foo" = 42', + 'null >> [12] = 42', + 'null >> class a {} = 42', + 'null >> function a(){} = 42', + 'null >> /[a]/ = 42', + 'null >> `foo` = 42', + // BooleanLiteral + 'true << true = 42', + 'true << 12 = 42', + 'true << "foo" = 42', + 'true << [12] = 42', + 'true << class a {} = 42', + 'true << function a(){} = 42', + 'true << /[a]/ = 42', + 'true << `foo` = 42', + 'true >> true = 42', + 'true >> 12 = 42', + 'true >> "foo" = 42', + 'true >> [12] = 42', + 'true >> class a {} = 42', + 'true >> function a(){} = 42', + 'true >> /[a]/ = 42', + 'true >> `foo` = 42', + // DecimalLiteral + '5 << 12 = 42', + '5 << "foo" = 42', + '5 << [12] = 42', + '5 << class a {} = 42', + '5 << function a(){} = 42', + '5 << /[a]/ = 42', + '5 << `foo` = 42', + '5 >> 12 = 42', + '5 >> "foo" = 42', + '5 >> [12] = 42', + '5 >> class a {} = 42', + '5 >> function a(){} = 42', + '5 >> /[a]/ = 42', + '5 >> `foo` = 42', + // StringLiteral + '"foo" << "foo" = 42', + '"foo" << [12] = 42', + '"foo" << class a {} = 42', + '"foo" << function a(){} = 42', + '"foo" << /[a]/ = 42', + '"foo" << `foo` = 42', + '"foo" >> "foo" = 42', + '"foo" >> [12] = 42', + '"foo" >> class a {} = 42', + '"foo" >> function a(){} = 42', + '"foo" >> /[a]/ = 42', + '"foo" >> `foo` = 42', + // ArrayLiteral + '[12] << [12] = 42', + '[12] << class a {} = 42', + '[12] << function a(){} = 42', + '[12] << /[a]/ = 42', + '[12] << `foo` = 42', + '[12] >> [12] = 42', + '[12] >> class a {} = 42', + '[12] >> function a(){} = 42', + '[12] >> /[a]/ = 42', + '[12] >> `foo` = 42', + // ObjectLiteral + 'this << {} = 42', + 'this >> {} = 42', + 'undefined << {} = 42', + 'undefined >> {} = 42', + 'null << {} = 42', + 'null >> {} = 42', + 'true << {} = 42', + 'true >> {} = 42', + '5 << {} = 42', + '5 >> {} = 42', + '"foo" << {} = 42', + '"foo" >> {} = 42', + '[12] << {} = 42', + '[12] >> {} = 42', + '/[a]/ << {} = 42', + '`foo` << {} = 42', + '/[a]/ >> {} = 42', + '`foo` >> {} = 42', + // RegularExpressionLiteral + '/[a]/ << class a{} = 42', + '/[a]/ << function a(){} = 42', + '/[a]/ << /[a]/ = 42', + '/[a]/ << `foo` = 42', + '/[a]/ >> class a{} = 42', + '/[a]/ >> function a(){} = 42', + '/[a]/ >> /[a]/ = 42', + '/[a]/ >> `foo` = 42', + // TemplateLiteral + '`foo` << class a{} = 42', + '`foo` << function a(){} = 42', + '`foo` << `foo` = 42', + '`foo` >> class a{} = 42', + '`foo` >> function a(){} = 42', + '`foo` >> `foo` = 42', + // combining with AdditiveExpression + '"foo" << 6 * 6 + !4 / 7 = 42', + 'void function a(){} >> +6 * !6 - ~4 / "foo" = 42', + 'var a = 5; 5 >>> ++a * "foo" << function a(){} = 42', + '`foo` << +/(?:)/ % 25 + void 6 / typeof class a {} = 42', + 'function a(){}; var b = new a(); 5 >>> ++a / !23 + !a = 42', + 'var a = {"foo": function(){}}; void "foo" % 12 >> typeof a.foo = 42', + 'var a = {"foo": function(){}}; -"foo" % 12 << typeof a.foo() = 42', + 'var a = [1,2,3]; a[2] << !a[0] % /[A]/ - delete 12 = 42', +]; + +for (var i = 0; i < tests.length; i++) +{ + try { + eval(tests[i]); + assert(false); + } catch (e) { + assert(e instanceof SyntaxError); + } +} diff --git a/tests/jerry/es.next/parser-typeof-op-assign.js b/tests/jerry/es.next/parser-typeof-op-assign.js new file mode 100644 index 000000000..e30d03aed --- /dev/null +++ b/tests/jerry/es.next/parser-typeof-op-assign.js @@ -0,0 +1,98 @@ +/* Copyright JS Foundation and other contributors, http://js.foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// tests for ECMA~262 v6 12.4.5 typeof UnaryExpression + +var tests = [ + // IdentifierReference + 'var obj = {a : 10, ret : function(params) {typeof a = 42;}}', + // NullLiteral + 'var a = null; typeof a = 42', + // BooleanLiteral + 'var a = true; typeof a = 42', + 'var a = false; typeof a = 42', + // DecimalLiteral + 'var a = 5; typeof a = 42', + 'var a = 1.23e4; typeof a = 42', + // BinaryIntegerLiteral + 'var a = 0b11; typeof a = 42', + 'var a = 0B11; typeof a = 42', + // OctalIntegerLiteral + 'var a = 0o66; typeof a = 42', + 'var a = 0O66; typeof a = 42', + // HexIntegerLiteral + 'var a = 0xFF; typeof a = 42', + 'var a = 0xFF; typeof a = 42', + // StringLiteral + 'var a = "foo"; typeof a = 42', + 'var a = "\\n"; typeof a = 42', + 'var a = "\\uFFFF"; typeof a = 42', + 'var a ="\\u{F}"; typeof a = 42', + // ArrayLiteral + 'var a = []; typeof a = 42', + 'var a = [1,a=5]; typeof a = 42', + // ObjectLiteral + 'var a = {}; typeof a = 42', + 'var a = {"foo" : 5}; typeof a = 42', + 'var a = {5 : 5}; typeof a = 42', + 'var a = {a : 5}; typeof a = 42', + 'var a = {[key] : 5}; typeof a = 42', + 'var a = {func(){}}; typeof a = 42', + 'var a = {get(){}}; typeof a = 42', + 'var a = {set(prop){}}; typeof a = 42', + 'var a = {*func(){}}; typeof a = 42', + // ClassExpression + 'class a {}; typeof a = 42', + 'class a {}; class b extends a {}; typeof b = 42', + 'class a {function(){}}; typeof a = 42', + // GeneratorExpression + 'function *a (){}; typeof a = 42', + // RegularExpressionLiteral + 'var a = /(?:)/; typeof a = 42', + 'var a = /a/; typeof a = 42', + 'var a = /[a]/; typeof a = 42', + 'var a = /a/g; typeof a = 42', + // TemplateLiteral + 'var a = ``; typeof a = 42', + 'a = 5; var b = (`${a}`); typeof b = 42', + 'var a = `foo`; typeof a = 42', + 'var a = `\\uFFFF`; typeof a = 42', + // MemberExpression + 'var a = [1,2,3]; typeof a[0] = 42', + 'var a = {0:12}; typeof a[0] = 42', + 'var a = {"foo":12}; typeof a.foo = 42', + 'var a = {func: function(){}}; typeof a.func = 42', + // SuperProperty + 'class a {constructor() {Object.defineProperty(this, \'foo\', {configurable:true, writable:true, value:1}); }} ' + + 'class b extends a {constructor() {super();} foo() {typeof super.foo = 42;}}', + // NewExpression + 'function a() {}; var b = new a(); typeof b = 42', + 'class a {}; var n = new a(); typeof a = 42', + 'class g {constructor() {Object.defineProperty(this, \'foo\', {configurable:true, writable:true, value:1}); }}; ' + + 'var a = new g(); typeof a = 42', + // CallExpression + 'function a(prop){return prop}; var b = a(12); typeof b = 42', +]; + +for (var i = 0; i < tests.length; i++) +{ + try { + eval(tests[i]); + assert(false); + } catch (e) { + assert(e instanceof SyntaxError); + } +} + \ No newline at end of file diff --git a/tests/jerry/es.next/parser-void-op-assign.js b/tests/jerry/es.next/parser-void-op-assign.js new file mode 100644 index 000000000..d093f5a93 --- /dev/null +++ b/tests/jerry/es.next/parser-void-op-assign.js @@ -0,0 +1,98 @@ +/* Copyright JS Foundation and other contributors, http://js.foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// tests for ECMA~262 v6 12.4.5 void UnaryExpression + +var tests = [ + // IdentifierReference + 'var obj = {a : 10, ret : function(params) {void a = 42;}}', + // NullLiteral + 'var a = null; void a = 42', + // BooleanLiteral + 'var a = true; void a = 42', + 'var a = false; void a = 42', + // DecimalLiteral + 'var a = 5; void a = 42', + 'var a = 1.23e4; void a = 42', + // BinaryIntegerLiteral + 'var a = 0b11; void a = 42', + 'var a = 0B11; void a = 42', + // OctalIntegerLiteral + 'var a = 0o66; void a = 42', + 'var a = 0O66; void a = 42', + // HexIntegerLiteral + 'var a = 0xFF; void a = 42', + 'var a = 0xFF; void a = 42', + // StringLiteral + 'var a = "foo"; void a = 42', + 'var a = "\\n"; void a = 42', + 'var a = "\\uFFFF"; void a = 42', + 'var a ="\\u{F}"; void a = 42', + // ArrayLiteral + 'var a = []; void a = 42', + 'var a = [1,a=5]; void a = 42', + // ObjectLiteral + 'var a = {}; void a = 42', + 'var a = {"foo" : 5}; void a = 42', + 'var a = {5 : 5}; void a = 42', + 'var a = {a : 5}; void a = 42', + 'var a = {[key] : 5}; void a = 42', + 'var a = {func(){}}; void a = 42', + 'var a = {get(){}}; void a = 42', + 'var a = {set(prop){}}; void a = 42', + 'var a = {*func(){}}; void a = 42', + // ClassExpression + 'class a {}; void a = 42', + 'class a {}; class b extends a {}; void b = 42', + 'class a {function(){}}; void a = 42', + // GeneratorExpression + 'function *a (){}; void a = 42', + // RegularExpressionLiteral + 'var a = /(?:)/; void a = 42', + 'var a = /a/; void a = 42', + 'var a = /[a]/; void a = 42', + 'var a = /a/g; void a = 42', + // TemplateLiteral + 'var a = ``; void a = 42', + 'a = 5; var b = (`${a}`); void b = 42', + 'var a = `foo`; void a = 42', + 'var a = `\\uFFFF`; void a = 42', + // MemberExpression + 'var a = [1,2,3]; void a[0] = 42', + 'var a = {0:12}; void a[0] = 42', + 'var a = {"foo":12}; void a.foo = 42', + 'var a = {func: function(){}}; void a.func = 42', + // SuperProperty + 'class a {constructor() {Object.defineProperty(this, \'foo\', {configurable:true, writable:true, value:1}); }} ' + + 'class b extends a {constructor() {super();} foo() {void super.foo = 42;}}', + // NewExpression + 'function a() {}; var b = new a(); void b = 42', + 'class g {constructor() {Object.defineProperty(this, \'foo\', {configurable:true, writable:true, value:1}); }}; ' + + 'var a = new g(); void a = 42', + 'class a {}; var n = new a(); void a = 42', + // CallExpression + 'function a(prop){return prop}; var b = a(12); void b = 42', +]; + +for (var i = 0; i < tests.length; i++) +{ + try { + eval(tests[i]); + assert(false); + } catch (e) { + assert(e instanceof SyntaxError); + } +} + \ No newline at end of file diff --git a/tests/jerry/es.next/regression-test-issue-2528.js b/tests/jerry/es.next/regression-test-issue-2528.js index 4e8f6ec8c..a8936c053 100644 --- a/tests/jerry/es.next/regression-test-issue-2528.js +++ b/tests/jerry/es.next/regression-test-issue-2528.js @@ -12,4 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -for (/a/ in a => { }, a => { }, a => { }) throw 1 +try { + eval('for (/a/ in a => { }, a => { }, a => { }) throw 1'); + assert(false); +} catch (e) { + assert(e instanceof SyntaxError); +} + diff --git a/tests/jerry/es.next/regression-test-issue-3519.js b/tests/jerry/es.next/regression-test-issue-3519.js index c51a7d80c..789dd1b77 100644 --- a/tests/jerry/es.next/regression-test-issue-3519.js +++ b/tests/jerry/es.next/regression-test-issue-3519.js @@ -12,8 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -function method () { - [""] = $ +try { + eval('function method () { [""] = $ }'); + assert(false); +} catch (e) { + assert(e instanceof SyntaxError); } try { diff --git a/tests/jerry/es.next/regression-test-issue-3589.js b/tests/jerry/es.next/regression-test-issue-3589.js index 52576dd89..a1fcde58b 100644 --- a/tests/jerry/es.next/regression-test-issue-3589.js +++ b/tests/jerry/es.next/regression-test-issue-3589.js @@ -13,15 +13,15 @@ // limitations under the License. try { - [this,000000000,this,99999999=9999999]; + eval('[this,000000000,this,99999999=9999999]'); assert(false); } catch (e) { - assert(e instanceof ReferenceError); + assert(e instanceof SyntaxError); } try { - [this,999+=8]; + eval('[this,999+=8]'); assert(false); } catch (e) { - assert(e instanceof ReferenceError); + assert(e instanceof SyntaxError); } diff --git a/tests/jerry/es.next/regression-test-issue-3815.js b/tests/jerry/es.next/regression-test-issue-3815.js new file mode 100644 index 000000000..dd555fb78 --- /dev/null +++ b/tests/jerry/es.next/regression-test-issue-3815.js @@ -0,0 +1,22 @@ +// Copyright JS Foundation and other contributors, http://js.foundation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +function a() {} + +try { + eval('(a()) = a'); + assert (false); +} catch (e) { + assert (e instanceof SyntaxError); +} diff --git a/tests/jerry/es.next/regression-test-issue-3819.js b/tests/jerry/es.next/regression-test-issue-3819.js index c635c1d1e..2a9df3bea 100644 --- a/tests/jerry/es.next/regression-test-issue-3819.js +++ b/tests/jerry/es.next/regression-test-issue-3819.js @@ -13,8 +13,8 @@ // limitations under the License. try { - typeof (global.v2) = 123; + eval('typeof (global.v2) = 123'); assert (false); } catch (e) { - assert (e instanceof ReferenceError); + assert (e instanceof SyntaxError); } diff --git a/tests/jerry/es.next/regression-test-issue-3820.js b/tests/jerry/es.next/regression-test-issue-3820.js index 8326181dd..6cd306cc7 100644 --- a/tests/jerry/es.next/regression-test-issue-3820.js +++ b/tests/jerry/es.next/regression-test-issue-3820.js @@ -13,8 +13,8 @@ // limitations under the License. try { - (isNaN(parseFloat("."))) = 'abcd'; + eval('(isNaN(parseFloat("."))) = \'abcd\''); assert (false); } catch (e) { - assert (e instanceof ReferenceError); + assert (e instanceof SyntaxError); } diff --git a/tests/jerry/es.next/regression-test-issue-3845.js b/tests/jerry/es.next/regression-test-issue-3845.js index 4edc090d1..e2c365b55 100644 --- a/tests/jerry/es.next/regression-test-issue-3845.js +++ b/tests/jerry/es.next/regression-test-issue-3845.js @@ -16,6 +16,6 @@ try { eval(`typeof (a) = 1 === 'undefined';`); assert(false); } catch (e) { - assert(e instanceof ReferenceError); + assert(e instanceof SyntaxError); } diff --git a/tests/jerry/arithmetic-parse.js b/tests/jerry/es5.1/arithmetic-parse.js similarity index 72% rename from tests/jerry/arithmetic-parse.js rename to tests/jerry/es5.1/arithmetic-parse.js index 15544bc99..8ec10256b 100644 --- a/tests/jerry/arithmetic-parse.js +++ b/tests/jerry/es5.1/arithmetic-parse.js @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -function parse (txt) { +function check_syntax_error (txt) { try { eval (txt) assert (false) @@ -25,25 +25,25 @@ var a = 21; var b = 10; var c; -parse ("c = a++b"); -parse ("c = a--b"); +check_syntax_error ("c = a++b"); +check_syntax_error ("c = a--b"); -parse ("c = a +* b"); -parse ("c = a -* b"); -parse ("c = a +/ b"); -parse ("c = a -/ b"); -parse ("c = a +% b"); -parse ("c = a -% b"); +check_syntax_error ("c = a +* b"); +check_syntax_error ("c = a -* b"); +check_syntax_error ("c = a +/ b"); +check_syntax_error ("c = a -/ b"); +check_syntax_error ("c = a +% b"); +check_syntax_error ("c = a -% b"); -parse ("a =* b"); -parse ("a =/ b"); -parse ("a =% b"); +check_syntax_error ("a =* b"); +check_syntax_error ("a =/ b"); +check_syntax_error ("a =% b"); -parse ("c = a+"); -parse ("c = a-"); +check_syntax_error ("c = a+"); +check_syntax_error ("c = a-"); -parse("a++\n()"); -parse("a--\n.b"); +check_syntax_error("a++\n()"); +check_syntax_error("a--\n.b"); assert((-2 .toString()) === -2); @@ -90,3 +90,4 @@ function h() assert(done); } h(); + \ No newline at end of file diff --git a/tests/jerry/arithmetics-2.js b/tests/jerry/es5.1/arithmetics.js similarity index 100% rename from tests/jerry/arithmetics-2.js rename to tests/jerry/es5.1/arithmetics.js diff --git a/tests/jerry/regression-test-issue-3815.js b/tests/jerry/es5.1/regression-test-issue-3815.js similarity index 100% rename from tests/jerry/regression-test-issue-3815.js rename to tests/jerry/es5.1/regression-test-issue-3815.js diff --git a/tests/test262-es6-excludelist.xml b/tests/test262-es6-excludelist.xml index 4f1fd00b1..9907772f0 100644 --- a/tests/test262-es6-excludelist.xml +++ b/tests/test262-es6-excludelist.xml @@ -1,5 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +