| 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..0219811d0082d41410b91c1e7af380a162f6a6a7
|
| --- /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* generator() {
|
| + yield 'a';
|
| + yield 'b';
|
| + yield 'c';
|
| +}
|
| +
|
| +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 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]);
|
| + }
|
| +}
|
| +
|
| +})();
|
|
|