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()); |
+} |