Debian Codegraph @

js/src/tests/test262/language/statements/with/unscopables-inc-dec.js

raw
1 // Copyright (C) 2017 Mozilla Corporation. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3
4 /*---
5 esid: sec-object-environment-records-hasbinding-n
6 description: >
7 @@unscopables should be looked up exactly once for inc/dec.
8 info: |
9 UpdateExpression : LeftHandSideExpression ++
10 1. Let lhs be the result of evaluating LeftHandSideExpression.
11
12 GetIdentifierReference ( lex, name, strict )
13 [...]
14 3. Let exists be ? envRec.HasBinding(name).
15
16 HasBinding ( N )
17 [...]
18 6. Let unscopables be ? Get(bindings, @@unscopables).
19 flags: [noStrict]
20 features: [Symbol.unscopables]
21 ---*/
22
23 var unscopablesGetterCalled = 0;
24 var a, b, flag = true;
25 with (a = { x: 7 }) {
26 with (b = { x: 4, get [Symbol.unscopables]() {
27 unscopablesGetterCalled++;
28 return { x: flag=!flag };
29 } }) {
30 x++;
31 }
32 }
33
34 assert.sameValue(unscopablesGetterCalled, 1);
35 assert.sameValue(a.x, 7);
36 assert.sameValue(b.x, 5);
37
38 unscopablesGetterCalled = 0;
39 flag = true;
40 with (a = { x: 7 }) {
41 with (b = { x: 4, get [Symbol.unscopables]() {
42 unscopablesGetterCalled++;
43 return { x: flag=!flag };
44 } }) {
45 x--;
46 }
47 }
48
49 assert.sameValue(unscopablesGetterCalled, 1);
50 assert.sameValue(a.x, 7);
51 assert.sameValue(b.x, 3);
52
53 reportCompare(0, 0);