forked from tc39/test262
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for change in Reference Records
These tests support the following normative change "Normative: Allow null or undefined in Reference Records" tc39/ecma262#2267 The tests concerning the `delete` operator increase coverage to verify behavior which, though related, is not altered by the normative change. These tests are intended to guard against regressions as engines implement the new semantics.
- Loading branch information
1 parent
5e0fc43
commit 7178371
Showing
12 changed files
with
320 additions
and
76 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
50 changes: 50 additions & 0 deletions
50
test/language/expressions/assignment/target-member-computed-reference-null.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Copyright (C) 2015 André Bargull. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-assignment-operators | ||
description: Assignment Operator evaluates the value prior validating a MemberExpression's reference (null) | ||
info: | | ||
# 13.15.2 Runtime Semantics: Evaluation | ||
AssignmentExpression : LeftHandSideExpression = AssignmentExpression | ||
1. If LeftHandSideExpression is neither an ObjectLiteral nor an ArrayLiteral, | ||
then | ||
a. Let lref be the result of evaluating LeftHandSideExpression. | ||
[...] | ||
e. Perform ? PutValue(lref, rval). | ||
# 6.2.4.5 PutValue ( V, W ) | ||
[...] | ||
5. If IsPropertyReference(V) is true, then | ||
a. Let baseObj be ? ToObject(V.[[Base]]). | ||
---*/ | ||
|
||
function DummyError() { } | ||
|
||
assert.throws(DummyError, function() { | ||
var base = null; | ||
var prop = function() { | ||
throw new DummyError(); | ||
}; | ||
var expr = function() { | ||
$ERROR("right-hand side expression evaluated"); | ||
}; | ||
|
||
base[prop()] = expr(); | ||
}); | ||
|
||
assert.throws(DummyError, function() { | ||
var base = null; | ||
var prop = { | ||
toString: function() { | ||
$ERROR("property key evaluated"); | ||
} | ||
}; | ||
var expr = function() { | ||
throw new DummyError(); | ||
}; | ||
|
||
base[prop] = expr(); | ||
}); |
50 changes: 50 additions & 0 deletions
50
test/language/expressions/assignment/target-member-computed-reference-undefined.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Copyright (C) 2015 André Bargull. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-assignment-operators | ||
description: Assignment Operator evaluates the value prior validating a MemberExpression's reference (undefined) | ||
info: | | ||
# 13.15.2 Runtime Semantics: Evaluation | ||
AssignmentExpression : LeftHandSideExpression = AssignmentExpression | ||
1. If LeftHandSideExpression is neither an ObjectLiteral nor an ArrayLiteral, | ||
then | ||
a. Let lref be the result of evaluating LeftHandSideExpression. | ||
[...] | ||
e. Perform ? PutValue(lref, rval). | ||
# 6.2.4.5 PutValue ( V, W ) | ||
[...] | ||
5. If IsPropertyReference(V) is true, then | ||
a. Let baseObj be ? ToObject(V.[[Base]]). | ||
---*/ | ||
|
||
function DummyError() { } | ||
|
||
assert.throws(DummyError, function() { | ||
var base = undefined; | ||
var prop = function() { | ||
throw new DummyError(); | ||
}; | ||
var expr = function() { | ||
$ERROR("right-hand side expression evaluated"); | ||
}; | ||
|
||
base[prop()] = expr(); | ||
}); | ||
|
||
assert.throws(DummyError, function() { | ||
var base = undefined; | ||
var prop = { | ||
toString: function() { | ||
$ERROR("property key evaluated"); | ||
} | ||
}; | ||
var expr = function() { | ||
throw new DummyError(); | ||
}; | ||
|
||
base[prop] = expr(); | ||
}); |
31 changes: 31 additions & 0 deletions
31
test/language/expressions/assignment/target-member-identifier-reference-null.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright (C) 2021 the V8 project authors. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-assignment-operators | ||
description: Assignment Operator evaluates the value prior validating a MemberExpression's reference (null) | ||
info: | | ||
# 13.15.2 Runtime Semantics: Evaluation | ||
AssignmentExpression : LeftHandSideExpression = AssignmentExpression | ||
1. If LeftHandSideExpression is neither an ObjectLiteral nor an ArrayLiteral, | ||
then | ||
a. Let lref be the result of evaluating LeftHandSideExpression. | ||
[...] | ||
e. Perform ? PutValue(lref, rval). | ||
# 6.2.4.5 PutValue ( V, W ) | ||
[...] | ||
5. If IsPropertyReference(V) is true, then | ||
a. Let baseObj be ? ToObject(V.[[Base]]). | ||
---*/ | ||
|
||
var count = 0; | ||
var base = null; | ||
|
||
assert.throws(TypeError, function() { | ||
base.prop = count += 1; | ||
}); | ||
|
||
assert.sameValue(count, 1); |
31 changes: 31 additions & 0 deletions
31
test/language/expressions/assignment/target-member-identifier-reference-undefined.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright (C) 2021 the V8 project authors. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-assignment-operators | ||
description: Assignment Operator evaluates the value prior validating a MemberExpression's reference (null) | ||
info: | | ||
# 13.15.2 Runtime Semantics: Evaluation | ||
AssignmentExpression : LeftHandSideExpression = AssignmentExpression | ||
1. If LeftHandSideExpression is neither an ObjectLiteral nor an ArrayLiteral, | ||
then | ||
a. Let lref be the result of evaluating LeftHandSideExpression. | ||
[...] | ||
e. Perform ? PutValue(lref, rval). | ||
# 6.2.4.5 PutValue ( V, W ) | ||
[...] | ||
5. If IsPropertyReference(V) is true, then | ||
a. Let baseObj be ? ToObject(V.[[Base]]). | ||
---*/ | ||
|
||
var count = 0; | ||
var base = undefined; | ||
|
||
assert.throws(TypeError, function() { | ||
base.prop = count += 1; | ||
}); | ||
|
||
assert.sameValue(count, 1); |
37 changes: 37 additions & 0 deletions
37
test/language/expressions/assignment/target-super-computed-reference-null.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Copyright (C) 2021 the V8 project authors. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-assignment-operators | ||
description: Assignment Operator evaluates the value prior validating a SuperProperty's reference (null) | ||
info: | | ||
# 13.15.2 Runtime Semantics: Evaluation | ||
AssignmentExpression : LeftHandSideExpression = AssignmentExpression | ||
1. If LeftHandSideExpression is neither an ObjectLiteral nor an ArrayLiteral, | ||
then | ||
a. Let lref be the result of evaluating LeftHandSideExpression. | ||
[...] | ||
e. Perform ? PutValue(lref, rval). | ||
# 6.2.4.5 PutValue ( V, W ) | ||
[...] | ||
5. If IsPropertyReference(V) is true, then | ||
a. Let baseObj be ? ToObject(V.[[Base]]). | ||
---*/ | ||
|
||
var count = 0; | ||
class C { | ||
static m() { | ||
super[0] = count += 1; | ||
} | ||
} | ||
|
||
Object.setPrototypeOf(C, null); | ||
|
||
assert.throws(TypeError, function() { | ||
C.m(); | ||
}); | ||
|
||
assert.sameValue(count, 1); |
37 changes: 37 additions & 0 deletions
37
test/language/expressions/assignment/target-super-identifier-reference-null.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Copyright (C) 2021 the V8 project authors. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-assignment-operators | ||
description: Assignment Operator evaluates the value prior validating a SuperProperty's reference (null) | ||
info: | | ||
# 13.15.2 Runtime Semantics: Evaluation | ||
AssignmentExpression : LeftHandSideExpression = AssignmentExpression | ||
1. If LeftHandSideExpression is neither an ObjectLiteral nor an ArrayLiteral, | ||
then | ||
a. Let lref be the result of evaluating LeftHandSideExpression. | ||
[...] | ||
e. Perform ? PutValue(lref, rval). | ||
# 6.2.4.5 PutValue ( V, W ) | ||
[...] | ||
5. If IsPropertyReference(V) is true, then | ||
a. Let baseObj be ? ToObject(V.[[Base]]). | ||
---*/ | ||
|
||
var count = 0; | ||
class C { | ||
static m() { | ||
super.x = count += 1; | ||
} | ||
} | ||
|
||
Object.setPrototypeOf(C, null); | ||
|
||
assert.throws(TypeError, function() { | ||
C.m(); | ||
}); | ||
|
||
assert.sameValue(count, 1); |
21 changes: 21 additions & 0 deletions
21
test/language/expressions/delete/member-computed-reference-null.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright (C) 2021 the V8 project authors. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-delete-operator | ||
description: Delete Operator throws an error if the base reference is not object-coercible (null). | ||
info: | | ||
# 12.5.3.2 Runtime Semantics: Evaluation | ||
UnaryExpression : delete UnaryExpression | ||
[...] | ||
5. If IsPropertyReference(ref) is true, then | ||
a. If IsSuperReference(ref) is true, throw a ReferenceError exception. | ||
b. Let baseObj be ? ToObject(ref.[[Base]]). | ||
---*/ | ||
|
||
var base = null; | ||
|
||
assert.throws(TypeError, function() { | ||
delete base[0]; | ||
}); |
21 changes: 21 additions & 0 deletions
21
test/language/expressions/delete/member-computed-reference-undefined.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright (C) 2021 the V8 project authors. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-delete-operator | ||
description: Delete Operator throws an error if the base reference is not object-coercible (undefined). | ||
info: | | ||
# 12.5.3.2 Runtime Semantics: Evaluation | ||
UnaryExpression : delete UnaryExpression | ||
[...] | ||
5. If IsPropertyReference(ref) is true, then | ||
a. If IsSuperReference(ref) is true, throw a ReferenceError exception. | ||
b. Let baseObj be ? ToObject(ref.[[Base]]). | ||
---*/ | ||
|
||
var base = undefined; | ||
|
||
assert.throws(TypeError, function() { | ||
delete base[0]; | ||
}); |
21 changes: 21 additions & 0 deletions
21
test/language/expressions/delete/member-identifier-reference-null.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright (C) 2021 the V8 project authors. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-delete-operator | ||
description: Delete Operator throws an error if the base reference is not object-coercible (null). | ||
info: | | ||
# 12.5.3.2 Runtime Semantics: Evaluation | ||
UnaryExpression : delete UnaryExpression | ||
[...] | ||
5. If IsPropertyReference(ref) is true, then | ||
a. If IsSuperReference(ref) is true, throw a ReferenceError exception. | ||
b. Let baseObj be ? ToObject(ref.[[Base]]). | ||
---*/ | ||
|
||
var base = null; | ||
|
||
assert.throws(TypeError, function() { | ||
delete base.prop; | ||
}); |
Oops, something went wrong.