summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/ion/setgname.js
blob: 4d684e81363eff28f92ef92cf8ceb1ee7c8baa41 (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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// aaa is initially undefined. Make sure it's set to the
// correct value - we have to store the type tag, even though
// its known type is int32.
var aaa;
function f() {
    function g(x) {
        if (x)
            aaa = 22;
    }
    g(10);

    function h() {
        aaa = 22;
    }
    for (var i=0; i<70; i++) {
        h();
    }
    assertEq(aaa, 22);
}
f();

x = 0;
function setX(i) {
    x = i;
}
for (var i=0; i<70; i++)
    setX(i);
assertEq(x, 69);

y = 3.14;
y = true;
y = [];
function setY(arg) {
    y = arg;
}
for (var i=0; i<70; i++)
    setY([1]);
setY([1, 2, 3]);
assertEq(y.length, 3);

// z is non-configurable, but can be made non-writable.
var z = 10;

function testNonWritable() {
    function g() {
        z = 11;
    }
    for (var i=0; i<70; i++) {
        g();
    }
    Object.defineProperty(this, "z", {value: 1234, writable: false});
    g();
    assertEq(z, 1234);
}
testNonWritable();