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. // 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: > description: >
Behavior when accessing `Symbol.unscopables` property value throws an error Behavior when accessing `Symbol.unscopables` property value throws an error
info: > info: |
[...] [...]
6. If the withEnvironment flag of envRec is false, return true. 2. Let envRec be lex's EnvironmentRecord.
7. Let unscopables be Get(bindings, @@unscopables). 3. Let exists be ? envRec.HasBinding(name).
8. ReturnIfAbrupt(unscopables).
ES6: 13.11.7 (The `with` Statement) Runtime Semantics: Evaluation 8.1.1.2.1 HasBinding
[...]
6. Set the withEnvironment flag of newEnvs EnvironmentRecord to true. [...]
[...] 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] flags: [noStrict]
features: [Symbol.unscopables] features: [Symbol.unscopables]
---*/ ---*/
@ -28,6 +35,6 @@ Object.defineProperty(env, Symbol.unscopables, {
with (env) { with (env) {
assert.throws(Test262Error, function() { 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. // 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: > description: >
`Symbol.unscopables` is not referenced when environment record does not have requested property `Symbol.unscopables` is not referenced when environment record does not have
info: > requested property
1. Let envRec be the object Environment Record for which the method was info: |
invoked. [...]
2. Let bindings be the binding object for envRec. 2. Let envRec be lex's EnvironmentRecord.
3. Let foundBinding be HasProperty(bindings, N) 3. Let exists be ? envRec.HasBinding(name).
4. ReturnIfAbrupt(foundBinding).
5. If foundBinding is false, return false.
ES6: 13.11.7 (The `with` Statement) Runtime Semantics: Evaluation 8.1.1.2.1 HasBinding
[...]
6. Set the withEnvironment flag of newEnvs EnvironmentRecord to true. 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] flags: [noStrict]
features: [Symbol.unscopables] features: [Symbol.unscopables]
---*/ ---*/
@ -31,7 +39,7 @@ Object.defineProperty(env, Symbol.unscopables, {
}); });
with (env) { with (env) {
void x; x;
} }
assert.sameValue(callCount, 0); assert.sameValue(callCount, 0);

View File

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