summaryrefslogtreecommitdiffstats
path: root/js/src/tests/ecma_5/strict/primitive-assignment.js
blob: 4b2ee79f0e4c35a514049d542db75934a5ea1938 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
let primitives = [
    10,
    false,
    "test",
    Symbol()
];

let key = "key";

for (let value of primitives) {
    // Doesn't throw outside strict mode.
    assertEq(value.x = 5, 5);
    assertEq(value[key] = 6, 6);

    assertThrowsInstanceOf(function() { "use strict"; value.x = 5; }, TypeError);
    assertThrowsInstanceOf(function() { "use strict"; value[key] = 6; }, TypeError);

    let target = {};
    assertEq(Reflect.set(target, key, 5, value), false);
    assertEq(key in target, false);
}

reportCompare(true, true);