Lines Matching refs:array
28 // Check that unshifting array of holes keeps the original array
29 // as array of holes
31 var array = new Array(10);
32 assertEquals(13, array.unshift('1st', '2ns', '3rd'));
33 assertTrue(0 in array);
34 assertTrue(1 in array);
35 assertTrue(2 in array);
36 assertFalse(3 in array);
45 var array = new Array(len);
50 Array.prototype[0] = at0;
51 Array.prototype[2] = at2;
53 // array owns nothing...
54 assertFalse(array.hasOwnProperty(0));
55 assertFalse(array.hasOwnProperty(1));
56 assertFalse(array.hasOwnProperty(2));
58 // ... but sees values from Array.prototype
59 assertEquals(array[0], at0);
60 assertEquals(array[1], undefined);
61 assertEquals(array[2], at2);
63 assertEquals(len, array.unshift());
65 assertTrue(delete Array.prototype[0]);
66 assertTrue(delete Array.prototype[2]);
68 // unshift makes array own 0 and 2...
69 assertTrue(array.hasOwnProperty(0));
70 assertFalse(array.hasOwnProperty(1));
71 assertTrue(array.hasOwnProperty(2));
74 assertEquals(array[0], at0);
75 assertEquals(array[1], undefined);
76 assertEquals(array[2], at2);
80 // Now check the case with array of holes and some elements on prototype.
83 var array = new Array(len);
84 Array.prototype[3] = "@3";
85 Array.prototype[7] = "@7";
87 assertEquals(len, array.length);
88 for (var i = 0; i < array.length; i++) {
89 assertEquals(array[i], Array.prototype[i]);
92 assertEquals(len + 1, array.unshift('head'));
94 assertEquals(len + 1, array.length);
95 // Note that unshift copies values from prototype into the array.
96 assertEquals(array[4], Array.prototype[3]);
97 assertTrue(array.hasOwnProperty(4));
99 assertEquals(array[8], Array.prototype[7]);
100 assertTrue(array.hasOwnProperty(8));
103 Array.prototype[5] = "@5";
104 assertEquals(array[5], Array.prototype[5]);
105 assertFalse(array.hasOwnProperty(5));
107 assertEquals(array[3], Array.prototype[3]);
108 assertFalse(array.hasOwnProperty(3));
110 assertEquals(array[7], Array.prototype[7]);
111 assertFalse(array.hasOwnProperty(7));
113 assertTrue(delete Array.prototype[3]);
114 assertTrue(delete Array.prototype[5]);
115 assertTrue(delete Array.prototype[7]);
122 new Array((1 << 32) - 3).unshift(1, 2, 3, 4, 5);
130 assertEquals(bigNum + 7, new Array(bigNum).unshift(1, 2, 3, 4, 5, 6, 7));