michael@0: function test1() { michael@0: var dense = [1, 2, 3]; michael@0: var denseHoles = [1, , 3]; michael@0: var result = 0; michael@0: michael@0: for (var i = 0; i < 70; i++) { michael@0: if (i in dense) result += 1; michael@0: if (1 in dense) result += 2; michael@0: if (3 in dense) result += 3; michael@0: if (-1000 in dense) result += 4; michael@0: if (i in denseHoles) result += 5; michael@0: if (1 in denseHoles) result += 6; michael@0: } michael@0: michael@0: assertEq(result, 153); michael@0: } michael@0: test1(); michael@0: michael@0: function test2() { michael@0: var a = [1, 2, 3]; michael@0: michael@0: for (var i = 0; i < 70; i++) { michael@0: assertEq(-0 in a, true); michael@0: assertEq(Math.sqrt(4) in a, true); michael@0: assertEq(1.9 in a, false); michael@0: assertEq(NaN in a, false); michael@0: assertEq(Infinity in a, false); michael@0: } michael@0: } michael@0: test2(); michael@0: michael@0: function test3() { michael@0: var a = [1, , 3]; michael@0: michael@0: for (var i = 0; i < 70; i++) { michael@0: if (i == 60) michael@0: Object.prototype[1] = null; michael@0: assertEq(1 in a, i >= 60); michael@0: } michael@0: } michael@0: test3();