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

Unified Diff: test/mjsunit/harmony/iterator-close.js

Issue 1778333002: Fix corner case in iterator finalization for array destructuring. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 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
« no previous file with comments | « src/parsing/pattern-rewriter.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/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; }
« no previous file with comments | « src/parsing/pattern-rewriter.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698