Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logical Assignment Operators: additional syntax tests #2560

Merged
merged 1 commit into from
Mar 31, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright (C) 2020 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-assignment-operators
description: >
Strict Mode - SyntaxError is thrown if the identifier arguments
appear as the LeftHandSideExpression of a Logical Assignment
operator(&&=)
flags: [onlyStrict]
negative:
phase: parse
type: SyntaxError
features: [logical-assignment-operators]
---*/
$DONOTEVALUATE();

arguments &&= 20;
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright (C) 2020 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-assignment-operators
description: >
Strict Mode - SyntaxError is thrown if the identifier eval appear
as the LeftHandSideExpression of a Logical Assignment operator(&&=)
flags: [onlyStrict]
negative:
phase: parse
type: SyntaxError
features: [logical-assignment-operators]
---*/
$DONOTEVALUATE();

eval &&= 20;
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright (C) 2020 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-assignment-operators-static-semantics-early-errors
info: |
It is an early Syntax Error if AssignmentTargetType of
LeftHandSideExpression is invalid or strict.
description: Logical "&&=" assignment with non-simple target
negative:
phase: parse
type: SyntaxError
features: [logical-assignment-operators]
---*/
$DONOTEVALUATE();

1 &&= 1;
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// Copyright (C) 2020 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
info: |
White Space and Line Terminator between LeftHandSideExpression and "@="
or between "@=" and AssignmentExpression are allowed
esid: sec-assignment-operators
description: Checking by evaluating expression "x[...]&&=[...]y"
features: [logical-assignment-operators]
---*/
var x;

x = 1;
assert.sameValue(x &&= 2, 2, 'U+0009 (expression)');
assert.sameValue(x, 2, 'U+0009 (side effect)');

x = 1;
assert.sameValue(x &&= 2, 2, 'U+000B (expression)');
assert.sameValue(x, 2, 'U+000B (side effect)');

x = 1;
assert.sameValue(x &&= 2, 2, 'U+000C (expression)');
assert.sameValue(x, 2, 'U+000C (side effect)');

x = 1;
assert.sameValue(x &&= 2, 2, 'U+0020 (expression)');
assert.sameValue(x, 2, 'U+0020 (side effect)');

x = 1;
assert.sameValue(x &&= 2, 2, 'U+00A0 (expression)');
assert.sameValue(x, 2, 'U+00A0 (side effect)');

x = 1;
assert.sameValue(x
&&=
2, 2, 'U+000A (expression)');
assert.sameValue(x, 2, 'U+000A (side effect)');

x = 1;
assert.sameValue(x
&&=
2, 2, 'U+000D (expression)');
assert.sameValue(x, 2, 'U+000D (side effect)');

x = 1;
assert.sameValue(x
&&=
2, 2, 'U+2028 (expression)');
assert.sameValue(x, 2, 'U+2028 (side effect)');

x = 1;
assert.sameValue(x
&&=
2, 2, 'U+2029 (expression)');
assert.sameValue(x, 2, 'U+2029 (side effect)');

x = 1;
assert.sameValue(x  


&&=  


2, 2, 'U+0009U+000BU+000CU+0020U+00A0U+000AU+000DU+2028U+2029 (expression)');
assert.sameValue(x, 2, 'U+0009U+000BU+000CU+0020U+00A0U+000AU+000DU+2028U+2029 (side effect)');
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright (C) 2020 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-assignment-operators
description: >
Strict Mode - SyntaxError is thrown if the identifier arguments
appear as the LeftHandSideExpression of a Logical Assignment
operator(??=)
flags: [onlyStrict]
negative:
phase: parse
type: SyntaxError
features: [logical-assignment-operators]
---*/
$DONOTEVALUATE();

arguments ??= 20;
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright (C) 2020 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-assignment-operators
description: >
Strict Mode - SyntaxError is thrown if the identifier eval appear
as the LeftHandSideExpression of a Logical Assignment operator(??=)
flags: [onlyStrict]
negative:
phase: parse
type: SyntaxError
features: [logical-assignment-operators]
---*/
$DONOTEVALUATE();

eval ??= 20;
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright (C) 2020 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-assignment-operators-static-semantics-early-errors
info: |
It is an early Syntax Error if AssignmentTargetType of
LeftHandSideExpression is invalid or strict.
description: Logical "??=" assignment with non-simple target
negative:
phase: parse
type: SyntaxError
features: [logical-assignment-operators]
---*/
$DONOTEVALUATE();

1 ??= 1;
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// Copyright (C) 2020 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
info: |
White Space and Line Terminator between LeftHandSideExpression and "@="
or between "@=" and AssignmentExpression are allowed
esid: sec-assignment-operators
description: Checking by evaluating expression "x[...]??=[...]y"
features: [logical-assignment-operators]
---*/
var x;

x = null;
assert.sameValue(x ??= 1, 1, 'U+0009 (expression)');
assert.sameValue(x, 1, 'U+0009 (side effect)');

x = null;
assert.sameValue(x ??= 1, 1, 'U+000B (expression)');
assert.sameValue(x, 1, 'U+000B (side effect)');

x = null;
assert.sameValue(x ??= 1, 1, 'U+000C (expression)');
assert.sameValue(x, 1, 'U+000C (side effect)');

x = null;
assert.sameValue(x ??= 1, 1, 'U+0020 (expression)');
assert.sameValue(x, 1, 'U+0020 (side effect)');

x = null;
assert.sameValue(x ??= 1, 1, 'U+00A0 (expression)');
assert.sameValue(x, 1, 'U+00A0 (side effect)');

x = null;
assert.sameValue(x
??=
1, 1, 'U+000A (expression)');
assert.sameValue(x, 1, 'U+000A (side effect)');

x = null;
assert.sameValue(x
??=
1, 1, 'U+000D (expression)');
assert.sameValue(x, 1, 'U+000D (side effect)');

x = null;
assert.sameValue(x
??=
1, 1, 'U+2028 (expression)');
assert.sameValue(x, 1, 'U+2028 (side effect)');

x = null;
assert.sameValue(x
??=
1, 1, 'U+2029 (expression)');
assert.sameValue(x, 1, 'U+2029 (side effect)');

x = null;
assert.sameValue(x  


??=  


1, 1, 'U+0009U+000BU+000CU+0020U+00A0U+000AU+000DU+2028U+2029 (expression)');
assert.sameValue(x, 1, 'U+0009U+000BU+000CU+0020U+00A0U+000AU+000DU+2028U+2029 (side effect)');
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright (C) 2020 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-assignment-operators
description: >
Strict Mode - SyntaxError is thrown if the identifier arguments
appear as the LeftHandSideExpression of a Logical Assignment
operator(||=)
flags: [onlyStrict]
negative:
phase: parse
type: SyntaxError
features: [logical-assignment-operators]
---*/
$DONOTEVALUATE();

arguments ||= 20;
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright (C) 2020 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-assignment-operators
description: >
Strict Mode - SyntaxError is thrown if the identifier eval appear
as the LeftHandSideExpression of a Logical Assignment operator(||=)
flags: [onlyStrict]
negative:
phase: parse
type: SyntaxError
features: [logical-assignment-operators]
---*/
$DONOTEVALUATE();

eval ||= 20;
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright (C) 2020 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-assignment-operators-static-semantics-early-errors
info: |
It is an early Syntax Error if AssignmentTargetType of
LeftHandSideExpression is invalid or strict.
description: Logical "||=" assignment with non-simple target
negative:
phase: parse
type: SyntaxError
features: [logical-assignment-operators]
---*/
$DONOTEVALUATE();

1 ||= 1;
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// Copyright (C) 2020 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
info: |
White Space and Line Terminator between LeftHandSideExpression and "@="
or between "@=" and AssignmentExpression are allowed
esid: sec-assignment-operators
description: Checking by evaluating expression "x[...]||=[...]y"
features: [logical-assignment-operators]
---*/
var x;

x = 0;
assert.sameValue(x ||= 1, 1, 'U+0009 (expression)');
assert.sameValue(x, 1, 'U+0009 (side effect)');

x = 0;
assert.sameValue(x ||= 1, 1, 'U+000B (expression)');
assert.sameValue(x, 1, 'U+000B (side effect)');

x = 0;
assert.sameValue(x ||= 1, 1, 'U+000C (expression)');
assert.sameValue(x, 1, 'U+000C (side effect)');

x = 0;
assert.sameValue(x ||= 1, 1, 'U+0020 (expression)');
assert.sameValue(x, 1, 'U+0020 (side effect)');

x = 0;
assert.sameValue(x ||= 1, 1, 'U+00A0 (expression)');
assert.sameValue(x, 1, 'U+00A0 (side effect)');

x = 0;
assert.sameValue(x
||=
1, 1, 'U+000A (expression)');
assert.sameValue(x, 1, 'U+000A (side effect)');

x = 0;
assert.sameValue(x
||=
1, 1, 'U+000D (expression)');
assert.sameValue(x, 1, 'U+000D (side effect)');

x = 0;
assert.sameValue(x
||=
1, 1, 'U+2028 (expression)');
assert.sameValue(x, 1, 'U+2028 (side effect)');

x = 0;
assert.sameValue(x
||=
1, 1, 'U+2029 (expression)');
assert.sameValue(x, 1, 'U+2029 (side effect)');

x = 0;
assert.sameValue(x  


||=  


1, 1, 'U+0009U+000BU+000CU+0020U+00A0U+000AU+000DU+2028U+2029 (expression)');
assert.sameValue(x, 1, 'U+0009U+000BU+000CU+0020U+00A0U+000AU+000DU+2028U+2029 (side effect)');