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

Unified Diff: test/mjsunit/es6/generators-states.js

Issue 1634553002: Fix bug where generators got closed prematurely. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Address comments. Created 4 years, 11 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
« no previous file with comments | « test/cctest/test-ast-expression-visitor.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/es6/generators-states.js
diff --git a/test/mjsunit/es6/generators-states.js b/test/mjsunit/es6/generators-states.js
index 0a2173a919fb9d24eadb1cc90dd6f29641d67822..4e8c58029a3a06218f84acb182c7fbf77d7e8547 100644
--- a/test/mjsunit/es6/generators-states.js
+++ b/test/mjsunit/es6/generators-states.js
@@ -25,6 +25,7 @@ function* throwGenerator() { yield iter.throw(new Bar); }
// Throw on a suspendedStart iterator.
iter = nextGenerator();
assertThrows(function() { iter.throw(new Foo) }, Foo)
+assertIteratorIsClosed(iter);
assertThrows(function() { iter.throw(new Foo) }, Foo)
assertIteratorIsClosed(iter);
@@ -65,3 +66,29 @@ iter = (function* () {
assertIteratorResult(3, false, iter.next());
assertIteratorResult(4, false, iter.next());
assertIteratorIsClosed(iter);
+
+
+// A return that doesn't close.
+{
+ let g = function*() { try {return 42} finally {yield 43} };
+
+ let x = g();
+ assertEquals({value: 43, done: false}, x.next());
+ assertEquals({value: 42, done: true}, x.next());
+}
+{
+ let x;
+ let g = function*() { try {return 42} finally {x.throw(666)} };
+
+ x = g();
+ assertThrows(() => x.next(), TypeError); // Still executing.
+}
+{
+ let x;
+ let g = function*() {
+ try {return 42} finally {try {x.throw(666)} catch(e) {}}
+ };
+
+ x = g();
+ assertEquals({value: 42, done: true}, x.next());
+}
« no previous file with comments | « test/cctest/test-ast-expression-visitor.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698