|
1 |
|
2 // aaa is initially undefined. Make sure it's set to the |
|
3 // correct value - we have to store the type tag, even though |
|
4 // its known type is int32. |
|
5 var aaa; |
|
6 function f() { |
|
7 function g(x) { |
|
8 if (x) |
|
9 aaa = 22; |
|
10 } |
|
11 g(10); |
|
12 |
|
13 function h() { |
|
14 aaa = 22; |
|
15 } |
|
16 for (var i=0; i<70; i++) { |
|
17 h(); |
|
18 } |
|
19 assertEq(aaa, 22); |
|
20 } |
|
21 f(); |
|
22 |
|
23 x = 0; |
|
24 function setX(i) { |
|
25 x = i; |
|
26 } |
|
27 for (var i=0; i<70; i++) |
|
28 setX(i); |
|
29 assertEq(x, 69); |
|
30 |
|
31 y = 3.14; |
|
32 y = true; |
|
33 y = []; |
|
34 function setY(arg) { |
|
35 y = arg; |
|
36 } |
|
37 for (var i=0; i<70; i++) |
|
38 setY([1]); |
|
39 setY([1, 2, 3]); |
|
40 assertEq(y.length, 3); |
|
41 |
|
42 // z is non-configurable, but can be made non-writable. |
|
43 var z = 10; |
|
44 |
|
45 function testNonWritable() { |
|
46 function g() { |
|
47 z = 11; |
|
48 } |
|
49 for (var i=0; i<70; i++) { |
|
50 g(); |
|
51 } |
|
52 Object.defineProperty(this, "z", {value: 1234, writable: false}); |
|
53 g(); |
|
54 assertEq(z, 1234); |
|
55 } |
|
56 testNonWritable(); |