Update parser early return type in ESNEXT (#3742)
This patch updates the early return types in the parser to SyntaxError instead of ReferenceError in ESNEXT This patch also includes a lot of tests for LeftHandSideExpression validation when using the = operator JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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:
|
||||
{
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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();
|
||||
@@ -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);
|
||||
@@ -309,5 +309,5 @@ try {
|
||||
eval ("var a = 0; 1 + [a] = [1]");
|
||||
assert (false);
|
||||
} catch (e) {
|
||||
assert (e instanceof ReferenceError);
|
||||
assert (e instanceof SyntaxError);
|
||||
}
|
||||
|
||||
@@ -230,5 +230,5 @@ try {
|
||||
eval ("var a = 0; -{a} = {a:1}");
|
||||
assert (false);
|
||||
} catch (e) {
|
||||
assert (e instanceof ReferenceError);
|
||||
assert (e instanceof SyntaxError);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -16,6 +16,6 @@ try {
|
||||
eval(`typeof (a) = 1 === 'undefined';`);
|
||||
assert(false);
|
||||
} catch (e) {
|
||||
assert(e instanceof ReferenceError);
|
||||
assert(e instanceof SyntaxError);
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -1,5 +1,36 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<excludeList>
|
||||
<!-- ES11 change: Should throw Syntaxerror -->
|
||||
<test id="language/types/boolean/S8.3_A2.1.js"><reason></reason></test>
|
||||
<test id="language/types/boolean/S8.3_A2.2.js"><reason></reason></test>
|
||||
<test id="language/types/reference/S8.7.2_A1_T1.js"><reason></reason></test>
|
||||
<test id="language/types/reference/S8.7.2_A1_T2.js"><reason></reason></test>
|
||||
<test id="language/reserved-words/S7.6.1_A1.1.js"><reason></reason></test>
|
||||
<test id="language/reserved-words/S7.6.1_A1.2.js"><reason></reason></test>
|
||||
<test id="language/reserved-words/S7.6.1_A1.3.js"><reason></reason></test>
|
||||
<test id="language/expressions/this/S11.1.1_A1.js"><reason></reason></test>
|
||||
<test id="language/keywords/S7.6.1.1_A1.18.js"><reason></reason></test>
|
||||
<test id="language/expressions/prefix-increment/non-simple.js"><reason></reason></test>
|
||||
<test id="language/expressions/prefix-decrement/non-simple.js"><reason></reason></test>
|
||||
<test id="language/expressions/postfix-increment/non-simple.js"><reason></reason></test>
|
||||
<test id="language/expressions/postfix-decrement/non-simple.js"><reason></reason></test>
|
||||
<test id="language/expressions/compound-assignment/add-non-simple.js"><reason></reason></test>
|
||||
<test id="language/expressions/compound-assignment/btws-and-non-simple.js"><reason></reason></test>
|
||||
<test id="language/expressions/compound-assignment/btws-or-non-simple.js"><reason></reason></test>
|
||||
<test id="language/expressions/compound-assignment/btws-xor-non-simple.js"><reason></reason></test>
|
||||
<test id="language/expressions/compound-assignment/div-non-simple.js"><reason></reason></test>
|
||||
<test id="language/expressions/compound-assignment/left-shift-non-simple.js"><reason></reason></test>
|
||||
<test id="language/expressions/compound-assignment/mod-div-non-simple.js"><reason></reason></test>
|
||||
<test id="language/expressions/compound-assignment/mult-non-simple.js"><reason></reason></test>
|
||||
<test id="language/expressions/compound-assignment/right-shift-non-simple.js"><reason></reason></test>
|
||||
<test id="language/expressions/compound-assignment/subtract-non-simple.js"><reason></reason></test>
|
||||
<test id="language/expressions/compound-assignment/u-right-shift-non-simple.js"><reason></reason></test>
|
||||
<test id="language/expressions/assignment/non-simple-target.js"><reason></reason></test>
|
||||
<test id="language/expressions/assignment/11.13.1-1-1.js"><reason></reason></test>
|
||||
<test id="language/expressions/assignment/11.13.1-1-2.js"><reason></reason></test>
|
||||
<test id="language/expressions/assignment/11.13.1-1-3.js"><reason></reason></test>
|
||||
<test id="language/expressions/assignment/11.13.1-1-4.js"><reason></reason></test>
|
||||
|
||||
<test id="annexB/B.2.3.10.js"><reason></reason></test>
|
||||
<test id="annexB/B.2.3.11.js"><reason></reason></test>
|
||||
<test id="annexB/B.2.3.12.js"><reason></reason></test>
|
||||
|
||||
Reference in New Issue
Block a user