Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(208)

Unified Diff: test/mjsunit/array-shift.js

Issue 596116: Elaborating test for Array.shift a bit. (Closed)
Patch Set: putting deletions into assertTrue Created 10 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/array-shift.js
diff --git a/test/mjsunit/array-shift.js b/test/mjsunit/array-shift.js
index 43439ab62193d610675d1395f11ea6c4b4b65b09..d985b31e0630e9e3d59450c31cb916094d892f9e 100644
--- a/test/mjsunit/array-shift.js
+++ b/test/mjsunit/array-shift.js
@@ -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]);
})();
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698