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

Unified Diff: test/mjsunit/harmony/generators-iteration.js

Issue 13542002: Calling a generator function returns a generator object (Closed) Base URL: git://github.com/v8/v8.git@master
Patch Set: Link generator iterator definitions and uses through local variable Created 7 years, 9 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
« src/runtime.cc ('K') | « src/runtime.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/harmony/generators-iteration.js
diff --git a/test/mjsunit/harmony/generators-iteration.js b/test/mjsunit/harmony/generators-iteration.js
index 1255f9705c479c5966cf916e378aef06033b8b7a..9cd895562183b586ad52f2458a6b616457b5f6d6 100644
--- a/test/mjsunit/harmony/generators-iteration.js
+++ b/test/mjsunit/harmony/generators-iteration.js
@@ -46,4 +46,23 @@ function TestContextAllocation() {
g5(["foo"]);
}
+// Test the properties and prototype of an iterator.
+function TestGeneratorIterator() {
+ function* g() { yield 1; }
+
+ var iterator = g();
+ assertSame(g.prototype, Object.getPrototypeOf(iterator));
+ assertTrue(iterator instanceof g);
+ assertEquals([], Object.getOwnPropertyNames(iterator));
+ assertTrue(iterator !== g());
+
+ // g() is the same as new g().
+ iterator = new g();
+ assertSame(g.prototype, Object.getPrototypeOf(iterator));
+ assertTrue(iterator instanceof g);
+ assertEquals([], Object.getOwnPropertyNames(iterator));
+ assertTrue(iterator !== new g());
+}
+
TestContextAllocation();
+TestGeneratorIterator();
« src/runtime.cc ('K') | « src/runtime.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698