OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 var typedArrayConstructors = [ | 5 var typedArrayConstructors = [ |
6 Uint8Array, | 6 Uint8Array, |
7 Int8Array, | 7 Int8Array, |
8 Uint16Array, | 8 Uint16Array, |
9 Int16Array, | 9 Int16Array, |
10 Uint32Array, | 10 Uint32Array, |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 // test array length remains same | 164 // test array length remains same |
165 assertEquals(large, arr.length); | 165 assertEquals(large, arr.length); |
166 }); | 166 }); |
167 | 167 |
168 | 168 |
169 CheckEachTypedArray(function copyWithinNullEnd(constructor) { | 169 CheckEachTypedArray(function copyWithinNullEnd(constructor) { |
170 // test null on third argument is converted to +0 | 170 // test null on third argument is converted to +0 |
171 assertArrayEquals([1, 2, 3, 4, 5], | 171 assertArrayEquals([1, 2, 3, 4, 5], |
172 new constructor([1, 2, 3, 4, 5]).copyWithin(0, 3, null)); | 172 new constructor([1, 2, 3, 4, 5]).copyWithin(0, 3, null)); |
173 }); | 173 }); |
174 | |
175 | |
176 CheckEachTypedArray(function copyWithinMinusInfinityTarget(constructor) { | |
177 var arr = new constructor([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); | |
178 var expected = [6, 7, 8, 9, 10, 6, 7, 8, 9, 10]; | |
179 | |
180 assertArrayEquals(expected, arr.copyWithin(-Infinity, 5)); | |
181 assertEquals(10, arr.length); | |
182 }); | |
183 | |
184 | |
185 CheckEachTypedArray(function copyWithinPositiveInfinityTarget(constructor) { | |
186 var arr = new constructor([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); | |
187 var expected = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; | |
188 | |
189 assertArrayEquals(expected, arr.copyWithin(+Infinity, 5)); | |
190 assertEquals(10, arr.length); | |
191 }); | |
192 | |
193 | |
194 CheckEachTypedArray(function copyWithinMinusInfinityStart(constructor) { | |
195 var arr = new constructor([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); | |
196 var expected = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5]; | |
197 | |
198 assertArrayEquals(expected, arr.copyWithin(5, -Infinity)); | |
199 assertEquals(10, arr.length); | |
200 }); | |
201 | |
202 | |
203 CheckEachTypedArray(function copyWithinPositiveInfinityStart(constructor) { | |
204 var arr = new constructor([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); | |
205 var expected = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; | |
206 | |
207 assertArrayEquals(expected, arr.copyWithin(5, +Infinity)); | |
208 assertEquals(10, arr.length); | |
209 }); | |
210 | |
211 | |
212 CheckEachTypedArray(function copyWithinMinusInfinityEnd(constructor) { | |
213 var arr = new constructor([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); | |
214 var expected = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; | |
215 | |
216 assertArrayEquals(expected, arr.copyWithin(5, 0, -Infinity)); | |
217 assertEquals(10, arr.length); | |
218 }); | |
219 | |
220 | |
221 CheckEachTypedArray(function copyWithinPositiveInfinityEnd(constructor) { | |
222 var arr = new constructor([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); | |
223 var expected = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5]; | |
224 | |
225 assertArrayEquals(expected, arr.copyWithin(5, 0, +Infinity)); | |
226 assertEquals(10, arr.length); | |
227 }); | |
OLD | NEW |