michael@0: michael@0: // aaa is initially undefined. Make sure it's set to the michael@0: // correct value - we have to store the type tag, even though michael@0: // its known type is int32. michael@0: var aaa; michael@0: function f() { michael@0: function g(x) { michael@0: if (x) michael@0: aaa = 22; michael@0: } michael@0: g(10); michael@0: michael@0: function h() { michael@0: aaa = 22; michael@0: } michael@0: for (var i=0; i<70; i++) { michael@0: h(); michael@0: } michael@0: assertEq(aaa, 22); michael@0: } michael@0: f(); michael@0: michael@0: x = 0; michael@0: function setX(i) { michael@0: x = i; michael@0: } michael@0: for (var i=0; i<70; i++) michael@0: setX(i); michael@0: assertEq(x, 69); michael@0: michael@0: y = 3.14; michael@0: y = true; michael@0: y = []; michael@0: function setY(arg) { michael@0: y = arg; michael@0: } michael@0: for (var i=0; i<70; i++) michael@0: setY([1]); michael@0: setY([1, 2, 3]); michael@0: assertEq(y.length, 3); michael@0: michael@0: // z is non-configurable, but can be made non-writable. michael@0: var z = 10; michael@0: michael@0: function testNonWritable() { michael@0: function g() { michael@0: z = 11; michael@0: } michael@0: for (var i=0; i<70; i++) { michael@0: g(); michael@0: } michael@0: Object.defineProperty(this, "z", {value: 1234, writable: false}); michael@0: g(); michael@0: assertEq(z, 1234); michael@0: } michael@0: testNonWritable();