OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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 // Flags: --harmony-arrays | |
6 | |
7 (function copyWithinArity() { | 5 (function copyWithinArity() { |
8 assertEquals(Array.prototype.copyWithin.length, 2); | 6 assertEquals(Array.prototype.copyWithin.length, 2); |
9 })(); | 7 })(); |
10 | 8 |
11 | 9 |
12 (function copyWithinTargetAndStart() { | 10 (function copyWithinTargetAndStart() { |
13 // works with two arguemnts | 11 // works with two arguemnts |
14 assertArrayEquals([4, 5, 3, 4, 5], [1, 2, 3, 4, 5].copyWithin(0, 3)); | 12 assertArrayEquals([4, 5, 3, 4, 5], [1, 2, 3, 4, 5].copyWithin(0, 3)); |
15 assertArrayEquals([1, 4, 5, 4, 5], [1, 2, 3, 4, 5].copyWithin(1, 3)); | 13 assertArrayEquals([1, 4, 5, 4, 5], [1, 2, 3, 4, 5].copyWithin(1, 3)); |
16 assertArrayEquals([1, 3, 4, 5, 5], [1, 2, 3, 4, 5].copyWithin(1, 2)); | 14 assertArrayEquals([1, 3, 4, 5, 5], [1, 2, 3, 4, 5].copyWithin(1, 2)); |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 (function copyWithinElementsInObjectsPrototype() { | 327 (function copyWithinElementsInObjectsPrototype() { |
330 // tamper the global Object prototype and test this works | 328 // tamper the global Object prototype and test this works |
331 Object.prototype[2] = 1; | 329 Object.prototype[2] = 1; |
332 assertArrayEquals([4, 5, 3, 4, 5], [1, 2, 3, 4, 5].copyWithin(0, 3)); | 330 assertArrayEquals([4, 5, 3, 4, 5], [1, 2, 3, 4, 5].copyWithin(0, 3)); |
333 delete Object.prototype[2]; | 331 delete Object.prototype[2]; |
334 | 332 |
335 Object.prototype[3] = "FAKE"; | 333 Object.prototype[3] = "FAKE"; |
336 assertArrayEquals(["FAKE", 5, 3, "FAKE", 5], [1, 2, 3, , 5].copyWithin(0, 3)); | 334 assertArrayEquals(["FAKE", 5, 3, "FAKE", 5], [1, 2, 3, , 5].copyWithin(0, 3)); |
337 delete Object.prototype[3]; | 335 delete Object.prototype[3]; |
338 })(); | 336 })(); |
OLD | NEW |