Elaborating test for Array.shift a bit.

Review URL: http://codereview.chromium.org/596116

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3855 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
antonm@chromium.org 2010-02-15 12:01:46 +00:00
parent 4507ca1523
commit 976ab7d7b5

View File

@ -34,13 +34,38 @@
// Now check the case with array of holes and some elements on prototype.
(function() {
var array = new Array(10);
var len = 9;
var array = new Array(len);
Array.prototype[3] = "@3";
Array.prototype[7] = "@7";
assertEquals(array[0], undefined);
assertEquals(array[7], Array.prototype[7]);
assertEquals(len, array.length);
for (var i = 0; i < array.length; i++) {
assertEquals(array[i], Array.prototype[i]);
}
array.shift();
assertEquals(array[0], undefined);
assertEquals(len - 1, array.length);
// Note that shift copies values from prototype into the array.
assertEquals(array[2], Array.prototype[3]);
assertTrue(array.hasOwnProperty(2));
assertEquals(array[6], Array.prototype[7]);
assertTrue(array.hasOwnProperty(6));
// ... but keeps the rest as holes:
Array.prototype[5] = "@5";
assertEquals(array[5], Array.prototype[5]);
assertFalse(array.hasOwnProperty(5));
assertEquals(array[3], Array.prototype[3]);
assertFalse(array.hasOwnProperty(3));
assertEquals(array[7], Array.prototype[7]);
assertFalse(array.hasOwnProperty(7));
assertTrue(delete Array.prototype[3]);
assertTrue(delete Array.prototype[5]);
assertTrue(delete Array.prototype[7]);
})();