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

Side by Side Diff: test/mjsunit/array-shift.js

Issue 2037008: Properly process arrays with overridden prototype in various Array's functions. (Closed)
Patch Set: Addressing Mads' comments Created 10 years, 7 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 unified diff | Download patch
« no previous file with comments | « test/mjsunit/array-pop.js ('k') | test/mjsunit/array-slice.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 assertEquals(array[3], Array.prototype[3]); 62 assertEquals(array[3], Array.prototype[3]);
63 assertFalse(array.hasOwnProperty(3)); 63 assertFalse(array.hasOwnProperty(3));
64 64
65 assertEquals(array[7], Array.prototype[7]); 65 assertEquals(array[7], Array.prototype[7]);
66 assertFalse(array.hasOwnProperty(7)); 66 assertFalse(array.hasOwnProperty(7));
67 67
68 assertTrue(delete Array.prototype[3]); 68 assertTrue(delete Array.prototype[3]);
69 assertTrue(delete Array.prototype[5]); 69 assertTrue(delete Array.prototype[5]);
70 assertTrue(delete Array.prototype[7]); 70 assertTrue(delete Array.prototype[7]);
71 })(); 71 })();
72
73 // Now check the case with array of holes and some elements on prototype
74 // which is an array itself.
75 (function() {
76 var len = 9;
77 var array = new Array(len);
78 var array_proto = new Array();
79 array_proto[3] = "@3";
80 array_proto[7] = "@7";
81 array.__proto__ = array_proto;
82
83 assertEquals(len, array.length);
84 for (var i = 0; i < array.length; i++) {
85 assertEquals(array[i], array_proto[i]);
86 }
87
88 array.shift();
89
90 assertEquals(len - 1, array.length);
91 // Note that shift copies values from prototype into the array.
92 assertEquals(array[2], array_proto[3]);
93 assertTrue(array.hasOwnProperty(2));
94
95 assertEquals(array[6], array_proto[7]);
96 assertTrue(array.hasOwnProperty(6));
97
98 // ... but keeps the rest as holes:
99 array_proto[5] = "@5";
100 assertEquals(array[5], array_proto[5]);
101 assertFalse(array.hasOwnProperty(5));
102
103 assertEquals(array[3], array_proto[3]);
104 assertFalse(array.hasOwnProperty(3));
105
106 assertEquals(array[7], array_proto[7]);
107 assertFalse(array.hasOwnProperty(7));
108 })();
OLDNEW
« no previous file with comments | « test/mjsunit/array-pop.js ('k') | test/mjsunit/array-slice.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698