From 6a3837fc0fb23ad02c208ff83e458325b7c1f645 Mon Sep 17 00:00:00 2001 From: Mike Pennisi Date: Wed, 15 Jun 2016 13:52:13 -0400 Subject: [PATCH] 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. --- .../statements/with/has-property-err.js | 36 ++++++++++++++++++ .../statements/with/unscopables-get-err.js | 31 +++++++++------ .../unscopables-not-referenced-for-undef.js | 36 +++++++++++------- .../with/unscopables-prop-get-err.js | 38 +++++++++++-------- 4 files changed, 100 insertions(+), 41 deletions(-) create mode 100644 test/language/statements/with/has-property-err.js diff --git a/test/language/statements/with/has-property-err.js b/test/language/statements/with/has-property-err.js new file mode 100644 index 0000000000..8379b6d22c --- /dev/null +++ b/test/language/statements/with/has-property-err.js @@ -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; + }); +} diff --git a/test/language/statements/with/unscopables-get-err.js b/test/language/statements/with/unscopables-get-err.js index be0cbb6a23..72ef9e116f 100644 --- a/test/language/statements/with/unscopables-get-err.js +++ b/test/language/statements/with/unscopables-get-err.js @@ -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 newEnv’s 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 newEnv’s 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; }); } diff --git a/test/language/statements/with/unscopables-not-referenced-for-undef.js b/test/language/statements/with/unscopables-not-referenced-for-undef.js index 0b5e3a602b..7feee61af9 100644 --- a/test/language/statements/with/unscopables-not-referenced-for-undef.js +++ b/test/language/statements/with/unscopables-not-referenced-for-undef.js @@ -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 newEnv’s 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 newEnv’s 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); diff --git a/test/language/statements/with/unscopables-prop-get-err.js b/test/language/statements/with/unscopables-prop-get-err.js index d5d16fe2c7..c83ab10086 100644 --- a/test/language/statements/with/unscopables-prop-get-err.js +++ b/test/language/statements/with/unscopables-prop-get-err.js @@ -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 newEnv’s 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 newEnv’s 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; }); }