mirror of https://github.com/tc39/test262.git
Add tests for change in Reference Records
These tests support the following normative change "Normative: Allow null or undefined in Reference Records" https://github.com/tc39/ecma262/pull/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.
This commit is contained in:
parent
93541f09e2
commit
9b4ca4371b
|
@ -1,38 +0,0 @@
|
||||||
// Copyright (C) 2015 André Bargull. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
info: Assignment Operator evaluates its operands from left to right.
|
|
||||||
description: >
|
|
||||||
The left-hand side expression is evaluated before the right-hand side.
|
|
||||||
Left-hand side expression is MemberExpression: base[prop]. base is the
|
|
||||||
null value.
|
|
||||||
---*/
|
|
||||||
|
|
||||||
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(TypeError, function() {
|
|
||||||
var base = null;
|
|
||||||
var prop = {
|
|
||||||
toString: function() {
|
|
||||||
$ERROR("property key evaluated");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
var expr = function() {
|
|
||||||
$ERROR("right-hand side expression evaluated");
|
|
||||||
};
|
|
||||||
|
|
||||||
base[prop] = expr();
|
|
||||||
});
|
|
|
@ -1,38 +0,0 @@
|
||||||
// Copyright (C) 2015 André Bargull. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
info: Assignment Operator evaluates its operands from left to right.
|
|
||||||
description: >
|
|
||||||
The left-hand side expression is evaluated before the right-hand side.
|
|
||||||
Left-hand side expression is MemberExpression: base[prop]. base is the
|
|
||||||
undefined value.
|
|
||||||
---*/
|
|
||||||
|
|
||||||
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(TypeError, function() {
|
|
||||||
var base = undefined;
|
|
||||||
var prop = {
|
|
||||||
toString: function() {
|
|
||||||
$ERROR("property key evaluated");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
var expr = function() {
|
|
||||||
$ERROR("right-hand side expression evaluated");
|
|
||||||
};
|
|
||||||
|
|
||||||
base[prop] = expr();
|
|
||||||
});
|
|
|
@ -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();
|
||||||
|
});
|
|
@ -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();
|
||||||
|
});
|
|
@ -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);
|
|
@ -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 (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]]).
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var count = 0;
|
||||||
|
var base = undefined;
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
base.prop = count += 1;
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.sameValue(count, 1);
|
|
@ -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);
|
|
@ -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);
|
|
@ -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];
|
||||||
|
});
|
|
@ -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];
|
||||||
|
});
|
|
@ -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;
|
||||||
|
});
|
|
@ -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.prop;
|
||||||
|
});
|
Loading…
Reference in New Issue