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 --harmony-generators | |
6 (function() { | |
7 | |
8 assertEquals(1, Array.from.length); | |
9 | |
10 function testArrayFrom(thisArg, constructor) { | |
11 assertArrayLikeEquals(Array.from.call(thisArg, generator()), ['a', 'b', 'c'], constructor); | |
12 } | |
13 | |
14 testArrayFrom(Array, Array); | |
15 testArrayFrom(null, Array); | |
16 testArrayFrom({}, Array); | |
17 testArrayFrom(Object, Object); | |
18 testArrayFrom(Other, Other); | |
19 | |
20 function Other() {} | |
21 | |
22 function* generator() { | |
arv (Not doing code reviews)
2014/09/05 18:04:54
Move this up, before the first usage.
| |
23 yield 'a'; | |
24 yield 'b'; | |
25 yield 'c'; | |
26 } | |
27 | |
28 function assertArrayLikeEquals(value, expected, type) { | |
29 assertInstanceof(value, type); | |
30 assertEquals(expected.length, value.length); | |
31 for (var i=0; i<value.length; ++i) { | |
32 assertEquals(expected[i], value[i]); | |
33 } | |
34 } | |
35 | |
36 })(); | |
OLD | NEW |