Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(110)

Unified Diff: test/mjsunit/harmony/array-from-generators.js

Issue 363833006: Implement Array.from() (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Disable generators tests for TurboFan Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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]);
+ }
+}
+
+})();

Powered by Google App Engine
This is Rietveld 408576698