tests/auto/qml/ecmascripttests/test262/test/language/statements/with/binding-not-blocked-by-unscopables-falsey-prop.js
raw symbols SCIP| 1 | // Copyright 2015 Mike Pennisi. All rights reserved. |
| 2 | // This code is governed by the BSD license found in the LICENSE file. |
| 3 | |
| 4 | /*--- |
| 5 | es6id: 8.1.1.2.1 |
| 6 | description: > |
| 7 | False-coercing `Symbol.unscopables` properties do not block access to object environment record |
| 8 | info: | |
| 9 | [...] |
| 10 | 6. If the withEnvironment flag of envRec is false, return true. |
| 11 | 7. Let unscopables be Get(bindings, @@unscopables). |
| 12 | 8. ReturnIfAbrupt(unscopables). |
| 13 | 9. If Type(unscopables) is Object, then |
| 14 | a. Let blocked be ToBoolean(Get(unscopables, N)). |
| 15 | b. ReturnIfAbrupt(blocked). |
| 16 | c. If blocked is true, return false. |
| 17 | 10. Return true. |
| 18 | |
| 19 | ES6: 13.11.7 (The `with` Statement) Runtime Semantics: Evaluation |
| 20 | [...] |
| 21 | 6. Set the withEnvironment flag of newEnv’s EnvironmentRecord to true. |
| 22 | [...] |
| 23 | flags: [noStrict] |
| 24 | features: [Symbol.unscopables] |
| 25 | ---*/ |
| 26 | |
| 27 | var x = 0; |
| 28 | var env = { x: 1 }; |
| 29 | env[Symbol.unscopables] = {}; |
| 30 | |
| 31 | with (env) { |
| 32 | assert.sameValue(x, 1, 'undefined (no property defined)'); |
| 33 | } |
| 34 | |
| 35 | env[Symbol.unscopables].x = false; |
| 36 | with (env) { |
| 37 | assert.sameValue(x, 1, 'literal `false` value'); |
| 38 | } |
| 39 | |
| 40 | env[Symbol.unscopables].x = undefined; |
| 41 | with (env) { |
| 42 | assert.sameValue(x, 1, 'literal `undefined` value'); |
| 43 | } |
| 44 | |
| 45 | env[Symbol.unscopables].x = null; |
| 46 | with (env) { |
| 47 | assert.sameValue(x, 1, 'null value'); |
| 48 | } |
| 49 | |
| 50 | env[Symbol.unscopables].x = 0; |
| 51 | with (env) { |
| 52 | assert.sameValue(x, 1, 'literal `0` number value'); |
| 53 | } |
| 54 | |
| 55 | env[Symbol.unscopables].x = ''; |
| 56 | with (env) { |
| 57 | assert.sameValue(x, 1, 'empty string value'); |
| 58 | } |