Add test for abrupt completion from HasBinding

Ensure that when HasBinding of an Object environment record returns an
abrupt completion, that same completion is returned to the runtime.
Update the meta-data of related tests for consistency with this new
test.
This commit is contained in:
Mike Pennisi 2016-06-15 13:52:13 -04:00 committed by Leonardo Balter
parent 10e4bdf0b6
commit 6a3837fc0f
No known key found for this signature in database
GPG Key ID: 3151533059133F60
4 changed files with 100 additions and 41 deletions

View File

@ -0,0 +1,36 @@
// Copyright (c) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-getidentifierreference
es6id: 8.1.2.1
description: >
Behavior when binding query produces an abrupt completion
info: |
[...]
2. Let envRec be lex's EnvironmentRecord.
3. Let exists be ? envRec.HasBinding(name).
8.1.1.2.1 HasBinding
1. Let envRec be the object Environment Record for which the method was
invoked.
2. Let bindings be the binding object for envRec.
3. Let foundBinding be ? HasProperty(bindings, N).
flags: [noStrict]
features: [Proxy]
---*/
var thrower = new Proxy({}, {
has: function(_, name) {
if (name === 'test262') {
throw new Test262Error();
}
}
});
with (thrower) {
assert.throws(Test262Error, function() {
test262;
});
}

View File

@ -2,19 +2,26 @@
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 8.1.1.2.1
esid: sec-getidentifierreference
es6id: 8.1.2.1
description: >
Behavior when accessing `Symbol.unscopables` property value throws an error
info: >
[...]
6. If the withEnvironment flag of envRec is false, return true.
7. Let unscopables be Get(bindings, @@unscopables).
8. ReturnIfAbrupt(unscopables).
Behavior when accessing `Symbol.unscopables` property value throws an error
info: |
[...]
2. Let envRec be lex's EnvironmentRecord.
3. Let exists be ? envRec.HasBinding(name).
ES6: 13.11.7 (The `with` Statement) Runtime Semantics: Evaluation
[...]
6. Set the withEnvironment flag of newEnvs EnvironmentRecord to true.
[...]
8.1.1.2.1 HasBinding
[...]
5. If the withEnvironment flag of envRec is false, return true.
6. Let unscopables be ? Get(bindings, @@unscopables).
13.11.7 (The `with` Statement) Runtime Semantics: Evaluation
[...]
5. Set the withEnvironment flag of newEnvs EnvironmentRecord to true.
[...]
flags: [noStrict]
features: [Symbol.unscopables]
---*/
@ -28,6 +35,6 @@ Object.defineProperty(env, Symbol.unscopables, {
with (env) {
assert.throws(Test262Error, function() {
void x;
x;
});
}

View File

@ -2,21 +2,29 @@
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 8.1.1.2.1
esid: sec-getidentifierreference
es6id: 8.1.2.1
description: >
`Symbol.unscopables` is not referenced when environment record does not have requested property
info: >
1. Let envRec be the object Environment Record for which the method was
invoked.
2. Let bindings be the binding object for envRec.
3. Let foundBinding be HasProperty(bindings, N)
4. ReturnIfAbrupt(foundBinding).
5. If foundBinding is false, return false.
`Symbol.unscopables` is not referenced when environment record does not have
requested property
info: |
[...]
2. Let envRec be lex's EnvironmentRecord.
3. Let exists be ? envRec.HasBinding(name).
ES6: 13.11.7 (The `with` Statement) Runtime Semantics: Evaluation
[...]
6. Set the withEnvironment flag of newEnvs EnvironmentRecord to true.
[...]
8.1.1.2.1 HasBinding
1. Let envRec be the object Environment Record for which the method was
invoked.
2. Let bindings be the binding object for envRec.
3. Let foundBinding be ? HasProperty(bindings, N).
4. If foundBinding is false, return false.
13.11.7 (The `with` Statement) Runtime Semantics: Evaluation
[...]
5. Set the withEnvironment flag of newEnvs EnvironmentRecord to true.
[...]
flags: [noStrict]
features: [Symbol.unscopables]
---*/
@ -31,7 +39,7 @@ Object.defineProperty(env, Symbol.unscopables, {
});
with (env) {
void x;
x;
}
assert.sameValue(callCount, 0);

View File

@ -2,22 +2,30 @@
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 8.1.1.2.1
esid: sec-getidentifierreference
es6id: 8.1.2.1
description: >
Behavior when accessing property of `Symbol.unscopables` property throws an error
info: >
[...]
6. If the withEnvironment flag of envRec is false, return true.
7. Let unscopables be Get(bindings, @@unscopables).
8. ReturnIfAbrupt(unscopables).
9. If Type(unscopables) is Object, then
a. Let blocked be ToBoolean(Get(unscopables, N)).
b. ReturnIfAbrupt(blocked).
Behavior when accessing property of `Symbol.unscopables` property throws an
error
info: |
[...]
2. Let envRec be lex's EnvironmentRecord.
3. Let exists be ? envRec.HasBinding(name).
ES6: 13.11.7 (The `with` Statement) Runtime Semantics: Evaluation
[...]
6. Set the withEnvironment flag of newEnvs EnvironmentRecord to true.
[...]
8.1.1.2.1 HasBinding
[...]
5. If the withEnvironment flag of envRec is false, return true.
6. Let unscopables be ? Get(bindings, @@unscopables).
7. If Type(unscopables) is Object, then
a. Let blocked be ToBoolean(? Get(unscopables, N)).
b. If blocked is true, return false.
13.11.7 (The `with` Statement) Runtime Semantics: Evaluation
[...]
5. Set the withEnvironment flag of newEnvs EnvironmentRecord to true.
[...]
flags: [noStrict]
features: [Symbol.unscopables]
---*/
@ -33,6 +41,6 @@ Object.defineProperty(env[Symbol.unscopables], 'x', {
with (env) {
assert.throws(Test262Error, function() {
void x;
x;
});
}