Index: test/mjsunit/harmony/iterator-close.js |
diff --git a/test/mjsunit/harmony/iterator-close.js b/test/mjsunit/harmony/iterator-close.js |
index 71ee4f5bfd403f2025204979576c83447116facb..09e01533077b6bd5b2d4860584c63149be42d07d 100644 |
--- a/test/mjsunit/harmony/iterator-close.js |
+++ b/test/mjsunit/harmony/iterator-close.js |
@@ -1010,6 +1010,94 @@ function* g() { yield 42; return 88 }; |
} |
+// Value throws. |
+{ |
+ g.prototype.next = () => ({get value() {throw 666}}); |
+ g.prototype.return = () => { assertUnreachable() }; |
+ |
+ |
+ assertThrowsEquals(() => { |
+ for (var x of g()) {} |
+ }, 666); |
+ |
+ assertThrowsEquals(() => { |
+ for (let x of g()) {} |
+ }, 666); |
+ |
+ assertThrowsEquals(() => { |
+ for (const x of g()) {} |
+ }, 666); |
+ |
+ assertThrowsEquals(() => { |
+ for (x of g()) {} |
+ }, 666); |
+ |
+ assertThrowsEquals(() => { |
+ var [x] = g(); |
+ }, 666); |
+ |
+ assertThrowsEquals(() => { |
+ let [x] = g(); |
+ }, 666); |
+ |
+ assertThrowsEquals(() => { |
+ const [x] = g(); |
+ }, 666); |
+ |
+ assertThrowsEquals(() => { |
+ [x] = g(); |
+ }, 666); |
+ |
+ assertThrowsEquals(() => { |
+ (([x]) => x)(g()); |
+ }, 666); |
+} |
+ |
+ |
+// Done throws. |
+{ |
+ g.prototype.next = () => ({get done() {throw 666}}); |
+ g.prototype.return = () => { assertUnreachable() }; |
+ |
+ |
+ assertThrowsEquals(() => { |
+ for (var x of g()) {} |
+ }, 666); |
+ |
+ assertThrowsEquals(() => { |
+ for (let x of g()) {} |
+ }, 666); |
+ |
+ assertThrowsEquals(() => { |
+ for (const x of g()) {} |
+ }, 666); |
+ |
+ assertThrowsEquals(() => { |
+ for (x of g()) {} |
+ }, 666); |
+ |
+ assertThrowsEquals(() => { |
+ var [x] = g(); |
+ }, 666); |
+ |
+ assertThrowsEquals(() => { |
+ let [x] = g(); |
+ }, 666); |
+ |
+ assertThrowsEquals(() => { |
+ const [x] = g(); |
+ }, 666); |
+ |
+ assertThrowsEquals(() => { |
+ [x] = g(); |
+ }, 666); |
+ |
+ assertThrowsEquals(() => { |
+ (([x]) => x)(g()); |
+ }, 666); |
+} |
+ |
+ |
// Nested loops. |
{ |
function* g1() { yield 1; yield 2; throw 3; } |