summaryrefslogtreecommitdiffstats
path: root/js/src/tests/ecma_6/LexicalEnvironment/unscopables-strict.js
blob: fd0413ed7ba18222001cc5aa8084951dabe1b075 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Strict assignment to the name of a property that's masked by @@unscopables
// throws a ReferenceError.

let env = {k: 1};
let f;
with (env) {
    f = function () {
        "use strict";
        k = 2;
    };
}

f();
assertEq(env.k, 2);

env[Symbol.unscopables] = {k: true};
assertThrowsInstanceOf(f, ReferenceError);

// @@unscopables is tested when the LHS of assignment is evaluated, so there is
// no effect on the assignment if it is changed while evaluating the RHS.
let g;
with (env) {
    g = function () {
        "use strict";
        k = (env[Symbol.unscopables].k = true, 3);
    }
}
env[Symbol.unscopables].k = false;
g();
assertEq(env.k, 3);

reportCompare(0, 0);