Index: test/mjsunit/harmony/array-from-generators.js |
diff --git a/test/mjsunit/harmony/array-from-generators.js b/test/mjsunit/harmony/array-from-generators.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..c8ff557dd373c6dbae7231b30e232b0d9d9457f8 |
--- /dev/null |
+++ b/test/mjsunit/harmony/array-from-generators.js |
@@ -0,0 +1,36 @@ |
+// Copyright 2014 the V8 project authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+// Flags: --harmony-arrays --harmony-generators |
+(function() { |
+ |
+assertEquals(1, Array.from.length); |
+ |
+function testArrayFrom(thisArg, constructor) { |
+ assertArrayLikeEquals(Array.from.call(thisArg, generator()), ['a', 'b', 'c'], constructor); |
+} |
+ |
+testArrayFrom(Array, Array); |
+testArrayFrom(null, Array); |
+testArrayFrom({}, Array); |
+testArrayFrom(Object, Object); |
+testArrayFrom(Other, Other); |
+ |
+function Other() {} |
+ |
+function* generator() { |
arv (Not doing code reviews)
2014/09/05 18:04:54
Move this up, before the first usage.
|
+ yield 'a'; |
+ yield 'b'; |
+ yield 'c'; |
+} |
+ |
+function assertArrayLikeEquals(value, expected, type) { |
+ assertInstanceof(value, type); |
+ assertEquals(expected.length, value.length); |
+ for (var i=0; i<value.length; ++i) { |
+ assertEquals(expected[i], value[i]); |
+ } |
+} |
+ |
+})(); |