OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 // Flags: --harmony-arrays | |
6 | |
7 assertEquals(1, Array.prototype.find.length); | |
8 | |
9 assertArrayEquals([0, 0, 0, 0, 0].fill(), [undefined, undefined, undefined, unde fined, undefined]); | |
10 assertArrayEquals([0, 0, 0, 0, 0].fill(8), [8, 8, 8, 8, 8]); | |
Dmitry Lomov (no reviews)
2014/04/28 11:18:25
Add test for empty array.
Add test for negative s
| |
11 assertArrayEquals([0, 0, 0, 0, 0].fill(8, 1), [0, 8, 8, 8, 8]); | |
12 assertArrayEquals([0, 0, 0, 0, 0].fill(8, 1, 4), [0, 8, 8, 8, 0]); | |
13 assertArrayEquals([0, 0, 0, 0, 0].fill(8, 1, -1), [0, 8, 8, 8, 0]); | |
14 assertArrayEquals([0, 0, 0, 0, 0].fill(8, 1, 42), [0, 8, 8, 8, 8]); | |
15 assertArrayEquals([0, 0, 0, 0, 0].fill(8, -3, 42), [0, 0, 8, 8, 8]); | |
16 assertArrayEquals([0, 0, 0, 0, 0].fill(8, -3, 4), [0, 0, 8, 8, 0]); | |
17 assertArrayEquals([0, 0, 0, 0, 0].fill(8, -2, -1), [0, 0, 0, 8, 0]); | |
18 assertArrayEquals([0, 0, 0, 0, 0].fill(8, -1, -3), [0, 0, 0, 0, 0]); | |
19 assertArrayEquals([0, 0, 0, 0, 0].fill(8, undefined, 4), [8, 8, 8, 8, 0]); | |
20 assertArrayEquals([ , , , , 0].fill(8, 1, 3), [, 8, 8, , 0]); | |
21 | |
22 // If the range if empty, the array is not actually modified and | |
23 // should not throw, even when applied to a frozen object. | |
24 assertArrayEquals(Object.freeze([1, 2, 3]).fill(0, 0, 0), [1, 2, 3]); | |
25 | |
26 // Test exceptions | |
27 assertThrows('Object.freeze([0]).fill()', TypeError); | |
28 assertThrows('Array.prototype.fill.call(null)', TypeError); | |
29 assertThrows('Array.prototype.fill.call(undefined)', TypeError); | |
OLD | NEW |