michael@0: /* michael@0: * Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/licenses/publicdomain/ michael@0: */ michael@0: michael@0: //----------------------------------------------------------------------------- michael@0: var BUGNUMBER = 909602; michael@0: var summary = michael@0: "Array.prototype.pop shouldn't touch elements greater than length on " + michael@0: "non-arrays"; michael@0: michael@0: print(BUGNUMBER + ": " + summary); michael@0: michael@0: /************** michael@0: * BEGIN TEST * michael@0: **************/ michael@0: michael@0: function doTest(obj, index) michael@0: { michael@0: // print("testing " + JSON.stringify(obj) + " with index " + index); michael@0: assertEq(Array.prototype.pop.call(obj), undefined); michael@0: assertEq(index in obj, true); michael@0: assertEq(obj[index], 42); michael@0: } michael@0: michael@0: // not-super-much-later element michael@0: michael@0: // non-zero length michael@0: function testPop1() michael@0: { michael@0: var obj = { length: 2, 3: 42 }; michael@0: doTest(obj, 3); michael@0: } michael@0: for (var i = 0; i < 50; i++) michael@0: testPop1(); michael@0: michael@0: // zero length michael@0: function testPop2() michael@0: { michael@0: var obj = { length: 0, 3: 42 }; michael@0: doTest(obj, 3); michael@0: } michael@0: for (var i = 0; i < 50; i++) michael@0: testPop2(); michael@0: michael@0: // much-later (but dense) element michael@0: michael@0: // non-zero length michael@0: function testPop3() michael@0: { michael@0: var obj = { length: 2, 55: 42 }; michael@0: doTest(obj, 55); michael@0: } michael@0: for (var i = 0; i < 50; i++) michael@0: testPop3(); michael@0: michael@0: // zero length michael@0: function testPop4() michael@0: { michael@0: var obj = { length: 0, 55: 42 }; michael@0: doTest(obj, 55); michael@0: } michael@0: for (var i = 0; i < 50; i++) michael@0: testPop4(); michael@0: michael@0: // much much much later (sparse) element michael@0: michael@0: // non-zero length michael@0: function testPop5() michael@0: { michael@0: var obj = { length: 2, 65530: 42 }; michael@0: doTest(obj, 65530); michael@0: } michael@0: for (var i = 0; i < 50; i++) michael@0: testPop5(); michael@0: michael@0: // zero length michael@0: function testPop6() michael@0: { michael@0: var obj = { length: 0, 65530: 42 }; michael@0: doTest(obj, 65530); michael@0: } michael@0: for (var i = 0; i < 50; i++) michael@0: testPop6(); michael@0: michael@0: /******************************************************************************/ michael@0: michael@0: if (typeof reportCompare === "function") michael@0: reportCompare(true, true); michael@0: michael@0: print("Tests complete");