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