Lines Matching refs:array
28 // Check that splicing array of holes keeps it as array of holes
31 var array = new Array(10);
32 var spliced = array.splice(1, 1, 'one', 'two');
36 assertEquals(11, array.length);
37 assertFalse(0 in array);
38 assertTrue(1 in array);
39 assertTrue(2 in array);
40 assertFalse(3 in array);
47 var array;
54 array = [1, 2, 3]
55 assertEquals(undefined, array.splice());
56 assertEquals([1, 2, 3], array);
62 array = [1, 2, 3]
63 assertEquals([1, 2, 3], array.splice(0));
64 assertEquals([], array);
66 array = [1, 2, 3]
67 assertEquals([1, 2, 3], array.splice(undefined));
68 assertEquals([], array);
70 array = [1, 2, 3]
71 assertEquals([1, 2, 3], array.splice("foobar"));
72 assertEquals([], array);
74 array = [1, 2, 3]
75 assertEquals([], array.splice(undefined, undefined));
76 assertEquals([1, 2, 3], array);
78 array = [1, 2, 3]
79 assertEquals([], array.splice("foobar", undefined));
80 assertEquals([1, 2, 3], array);
82 array = [1, 2, 3]
83 assertEquals([], array.splice(undefined, "foobar"));
84 assertEquals([1, 2, 3], array);
86 array = [1, 2, 3]
87 assertEquals([], array.splice("foobar", "foobar"));
88 assertEquals([1, 2, 3], array);
95 var array, spliced;
97 array = [1, 2, 3, 4, 5, 6, 7];
98 spliced = array.splice(-100);
99 assertEquals([], array);
102 array = [1, 2, 3, 4, 5, 6, 7];
103 spliced = array.splice(-3);
104 assertEquals([1, 2, 3, 4], array);
107 array = [1, 2, 3, 4, 5, 6, 7];
108 spliced = array.splice(4);
109 assertEquals([1, 2, 3, 4], array);
112 array = [1, 2, 3, 4, 5, 6, 7];
113 spliced = array.splice(6);
114 assertEquals([1, 2, 3, 4, 5, 6], array);
117 array = [1, 2, 3, 4, 5, 6, 7];
118 spliced = array.splice(7);
119 assertEquals([1, 2, 3, 4, 5, 6, 7], array);
122 array = [1, 2, 3, 4, 5, 6, 7];
123 spliced = array.splice(8);
124 assertEquals([1, 2, 3, 4, 5, 6, 7], array);
127 array = [1, 2, 3, 4, 5, 6, 7];
128 spliced = array.splice(100);
129 assertEquals([1, 2, 3, 4, 5, 6, 7], array);
132 array = [1, 2, 3, 4, 5, 6, 7];
133 spliced = array.splice(0, -100);
134 assertEquals([1, 2, 3, 4, 5, 6, 7], array);
137 array = [1, 2, 3, 4, 5, 6, 7];
138 spliced = array.splice(0, -3);
139 assertEquals([1, 2, 3, 4, 5, 6, 7], array);
142 array = [1, 2, 3, 4, 5, 6, 7];
143 spliced = array.splice(0, 4);
144 assertEquals([5, 6, 7], array);
147 array = [1, 2, 3, 4, 5, 6, 7];
148 spliced = array.splice(0, 6);
149 assertEquals([7], array);
152 array = [1, 2, 3, 4, 5, 6, 7];
153 spliced = array.splice(0, 7);
154 assertEquals([], array);
157 array = [1, 2, 3, 4, 5, 6, 7];
158 spliced = array.splice(0, 8);
159 assertEquals([], array);
162 array = [1, 2, 3, 4, 5, 6, 7];
163 spliced = array.splice(0, 100);
164 assertEquals([], array);
185 array = [1, 2, 3];
186 array.splice(0, 3, obj);
187 assertEquals(1, array.length);
190 array = [1, 2, 3];
191 spliced = array.splice({valueOf: function() { return 1; }},
195 assertEquals([1, 'one', 'two'], array);
200 // Nasty: modify the array in ToInteger.
202 var array = [];
206 bad_start = { valueOf: function() { array.push(2*i); return -1; } };
207 bad_count = { valueOf: function() { array.push(2*i + 1); return 1; } };
208 spliced = array.splice(bad_start, bad_count);
212 array.push(2*i); array.push(2*i + 1);
215 assertEquals([0, 1], array);
217 // When we start splice, array is [0 .. 2*i - 1], so we get
218 // as a result [2*i], this element is removed from the array,
221 assertEquals(2 * i, array[i]);
222 assertEquals(2 * i + 1, array[i + 1]);
228 // Now check the case with array of holes and some elements on prototype.
236 var array = new Array(len);
237 Array.prototype[3] = at3;
238 Array.prototype[7] = at7;
240 var spliced = array.splice(2, 2, 'one', undefined, 'two');
242 // Second hole (at index 3) of array turns into
243 // value of Array.prototype[3] while copying.
245 assertEquals([, , 'one', undefined, 'two', , , at7, at7, ,], array);
247 // ... but array[7] is actually a hole:
248 assertTrue(delete Array.prototype[7]);
249 assertEquals(undefined, array[7]);
252 assertFalse(array.hasOwnProperty(0));
253 assertFalse(array.hasOwnProperty(1));
254 assertTrue(array.hasOwnProperty(2));
255 assertTrue(array.hasOwnProperty(3));
256 assertTrue(array.hasOwnProperty(4));
257 assertFalse(array.hasOwnProperty(5));
258 assertFalse(array.hasOwnProperty(6));
259 assertFalse(array.hasOwnProperty(7));
260 assertTrue(array.hasOwnProperty(8));
261 assertFalse(array.hasOwnProperty(9));
264 assertFalse(array.hasOwnProperty(10));
265 assertFalse(array.hasOwnProperty(15));
266 assertFalse(array.hasOwnProperty(31));
267 assertFalse(array.hasOwnProperty(63));
268 assertFalse(array.hasOwnProperty(2 << 32 - 1));
277 new Array((1 << 32) - 3).splice(-1, 0, 1, 2, 3, 4, 5);
285 var array = new Array(bigNum);
286 array.splice(-1, 0, 1, 2, 3, 4, 5, 6, 7);
287 assertEquals(bigNum + 7, array.length);