From 93e8924ec512bc574d8ced574dce988a2bcf7c5b Mon Sep 17 00:00:00 2001 From: Leo Balter Date: Mon, 15 May 2017 15:47:44 -0400 Subject: [PATCH 1/2] Add templates for dstr-binding w/ for-await-of looping over async iterators --- ...r-await-of-async-func-const-async.template | 54 +++++++++++++++++++ ...for-await-of-async-func-let-async.template | 54 +++++++++++++++++++ ...for-await-of-async-func-var-async.template | 54 +++++++++++++++++++ ...or-await-of-async-gen-const-async.template | 54 +++++++++++++++++++ .../for-await-of-async-gen-let-async.template | 54 +++++++++++++++++++ .../for-await-of-async-gen-var-async.template | 54 +++++++++++++++++++ 6 files changed, 324 insertions(+) create mode 100644 src/dstr-binding/default/for-await-of-async-func-const-async.template create mode 100644 src/dstr-binding/default/for-await-of-async-func-let-async.template create mode 100644 src/dstr-binding/default/for-await-of-async-func-var-async.template create mode 100644 src/dstr-binding/default/for-await-of-async-gen-const-async.template create mode 100644 src/dstr-binding/default/for-await-of-async-gen-let-async.template create mode 100644 src/dstr-binding/default/for-await-of-async-gen-var-async.template diff --git a/src/dstr-binding/default/for-await-of-async-func-const-async.template b/src/dstr-binding/default/for-await-of-async-func-const-async.template new file mode 100644 index 0000000000..a897bc9695 --- /dev/null +++ b/src/dstr-binding/default/for-await-of-async-func-const-async.template @@ -0,0 +1,54 @@ +// Copyright (C) 2017 Mozilla Corporation. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/for-await-of/async-func-dstr-const-async- +name: for-await-of statement +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [/*{ vals }*/]; +})(); + +async function fn() { + for await (const /*{ elems }*/ of asyncIter) { + /*{ body }*/ + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-binding/default/for-await-of-async-func-let-async.template b/src/dstr-binding/default/for-await-of-async-func-let-async.template new file mode 100644 index 0000000000..6f971f061d --- /dev/null +++ b/src/dstr-binding/default/for-await-of-async-func-let-async.template @@ -0,0 +1,54 @@ +// Copyright (C) 2017 Mozilla Corporation. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/for-await-of/async-func-dstr-let-async- +name: for-await-of statement +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [/*{ vals }*/]; +})(); + +async function fn() { + for await (let /*{ elems }*/ of asyncIter) { + /*{ body }*/ + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-binding/default/for-await-of-async-func-var-async.template b/src/dstr-binding/default/for-await-of-async-func-var-async.template new file mode 100644 index 0000000000..1682320824 --- /dev/null +++ b/src/dstr-binding/default/for-await-of-async-func-var-async.template @@ -0,0 +1,54 @@ +// Copyright (C) 2017 Mozilla Corporation. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/for-await-of/async-func-dstr-var-async- +name: for-await-of statement +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [/*{ vals }*/]; +})(); + +async function fn() { + for await (var /*{ elems }*/ of asyncIter) { + /*{ body }*/ + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-binding/default/for-await-of-async-gen-const-async.template b/src/dstr-binding/default/for-await-of-async-gen-const-async.template new file mode 100644 index 0000000000..592433e70b --- /dev/null +++ b/src/dstr-binding/default/for-await-of-async-gen-const-async.template @@ -0,0 +1,54 @@ +// Copyright (C) 2017 Mozilla Corporation. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/for-await-of/async-gen-dstr-const-async- +name: for-await-of statement +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [/*{ vals }*/]; +})(); + +async function *fn() { + for await (const /*{ elems }*/ of asyncIter) { + /*{ body }*/ + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-binding/default/for-await-of-async-gen-let-async.template b/src/dstr-binding/default/for-await-of-async-gen-let-async.template new file mode 100644 index 0000000000..aeb133ad46 --- /dev/null +++ b/src/dstr-binding/default/for-await-of-async-gen-let-async.template @@ -0,0 +1,54 @@ +// Copyright (C) 2017 Mozilla Corporation. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/for-await-of/async-gen-dstr-let-async- +name: for-await-of statement +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [/*{ vals }*/]; +})(); + +async function *fn() { + for await (let /*{ elems }*/ of asyncIter) { + /*{ body }*/ + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-binding/default/for-await-of-async-gen-var-async.template b/src/dstr-binding/default/for-await-of-async-gen-var-async.template new file mode 100644 index 0000000000..c251fda071 --- /dev/null +++ b/src/dstr-binding/default/for-await-of-async-gen-var-async.template @@ -0,0 +1,54 @@ +// Copyright (C) 2017 Mozilla Corporation. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/for-await-of/async-gen-dstr-var-async- +name: for-await-of statement +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [/*{ vals }*/]; +})(); + +async function *fn() { + for await (var /*{ elems }*/ of asyncIter) { + /*{ body }*/ + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); From 8d7e98265c41b953dc6fa5d46f9bf06e374b17a7 Mon Sep 17 00:00:00 2001 From: Leo Balter Date: Mon, 15 May 2017 16:01:04 -0400 Subject: [PATCH 2/2] Generate tests --- ...nc-dstr-const-async-ary-init-iter-close.js | 77 +++++++++++++++ ...dstr-const-async-ary-init-iter-no-close.js | 77 +++++++++++++++ ...func-dstr-const-async-ary-name-iter-val.js | 76 +++++++++++++++ ...const-async-ary-ptrn-elem-ary-elem-init.js | 68 +++++++++++++ ...const-async-ary-ptrn-elem-ary-elem-iter.js | 69 ++++++++++++++ ...st-async-ary-ptrn-elem-ary-elision-init.js | 75 +++++++++++++++ ...st-async-ary-ptrn-elem-ary-elision-iter.js | 72 ++++++++++++++ ...onst-async-ary-ptrn-elem-ary-empty-init.js | 70 ++++++++++++++ ...onst-async-ary-ptrn-elem-ary-empty-iter.js | 68 +++++++++++++ ...const-async-ary-ptrn-elem-ary-rest-init.js | 72 ++++++++++++++ ...const-async-ary-ptrn-elem-ary-rest-iter.js | 75 +++++++++++++++ ...t-async-ary-ptrn-elem-id-init-exhausted.js | 67 +++++++++++++ ...ync-ary-ptrn-elem-id-init-fn-name-arrow.js | 68 +++++++++++++ ...ync-ary-ptrn-elem-id-init-fn-name-class.js | 70 ++++++++++++++ ...ync-ary-ptrn-elem-id-init-fn-name-cover.js | 69 ++++++++++++++ ...-async-ary-ptrn-elem-id-init-fn-name-fn.js | 69 ++++++++++++++ ...async-ary-ptrn-elem-id-init-fn-name-gen.js | 69 ++++++++++++++ ...-const-async-ary-ptrn-elem-id-init-hole.js | 63 ++++++++++++ ...nst-async-ary-ptrn-elem-id-init-skipped.js | 72 ++++++++++++++ ...const-async-ary-ptrn-elem-id-init-undef.js | 66 +++++++++++++ ...st-async-ary-ptrn-elem-id-iter-complete.js | 70 ++++++++++++++ ...-const-async-ary-ptrn-elem-id-iter-done.js | 65 +++++++++++++ ...r-const-async-ary-ptrn-elem-id-iter-val.js | 76 +++++++++++++++ ...r-const-async-ary-ptrn-elem-obj-id-init.js | 68 +++++++++++++ ...c-dstr-const-async-ary-ptrn-elem-obj-id.js | 68 +++++++++++++ ...st-async-ary-ptrn-elem-obj-prop-id-init.js | 78 +++++++++++++++ ...r-const-async-ary-ptrn-elem-obj-prop-id.js | 78 +++++++++++++++ ...-const-async-ary-ptrn-elision-exhausted.js | 73 ++++++++++++++ ...-func-dstr-const-async-ary-ptrn-elision.js | 82 ++++++++++++++++ ...nc-func-dstr-const-async-ary-ptrn-empty.js | 65 +++++++++++++ ...dstr-const-async-ary-ptrn-rest-ary-elem.js | 89 +++++++++++++++++ ...r-const-async-ary-ptrn-rest-ary-elision.js | 95 +++++++++++++++++++ ...str-const-async-ary-ptrn-rest-ary-empty.js | 78 +++++++++++++++ ...dstr-const-async-ary-ptrn-rest-ary-rest.js | 74 +++++++++++++++ ...tr-const-async-ary-ptrn-rest-id-elision.js | 70 ++++++++++++++ ...-const-async-ary-ptrn-rest-id-exhausted.js | 66 +++++++++++++ ...-func-dstr-const-async-ary-ptrn-rest-id.js | 67 +++++++++++++ ...dstr-const-async-ary-ptrn-rest-init-ary.js | 63 ++++++++++++ ...-dstr-const-async-ary-ptrn-rest-init-id.js | 63 ++++++++++++ ...dstr-const-async-ary-ptrn-rest-init-obj.js | 63 ++++++++++++ ...const-async-ary-ptrn-rest-not-final-ary.js | 63 ++++++++++++ ...-const-async-ary-ptrn-rest-not-final-id.js | 63 ++++++++++++ ...const-async-ary-ptrn-rest-not-final-obj.js | 63 ++++++++++++ ...c-dstr-const-async-ary-ptrn-rest-obj-id.js | 67 +++++++++++++ ...r-const-async-ary-ptrn-rest-obj-prop-id.js | 74 +++++++++++++++ ...nc-func-dstr-const-async-obj-ptrn-empty.js | 66 +++++++++++++ ...st-async-obj-ptrn-id-init-fn-name-arrow.js | 67 +++++++++++++ ...st-async-obj-ptrn-id-init-fn-name-class.js | 69 ++++++++++++++ ...st-async-obj-ptrn-id-init-fn-name-cover.js | 68 +++++++++++++ ...const-async-obj-ptrn-id-init-fn-name-fn.js | 68 +++++++++++++ ...onst-async-obj-ptrn-id-init-fn-name-gen.js | 68 +++++++++++++ ...tr-const-async-obj-ptrn-id-init-skipped.js | 71 ++++++++++++++ ...-const-async-obj-ptrn-id-trailing-comma.js | 61 ++++++++++++ ...dstr-const-async-obj-ptrn-prop-ary-init.js | 70 ++++++++++++++ ...-async-obj-ptrn-prop-ary-trailing-comma.js | 61 ++++++++++++ ...func-dstr-const-async-obj-ptrn-prop-ary.js | 68 +++++++++++++ ...nst-async-obj-ptrn-prop-id-init-skipped.js | 83 ++++++++++++++++ ...-dstr-const-async-obj-ptrn-prop-id-init.js | 64 +++++++++++++ ...t-async-obj-ptrn-prop-id-trailing-comma.js | 65 +++++++++++++ ...-func-dstr-const-async-obj-ptrn-prop-id.js | 64 +++++++++++++ ...dstr-const-async-obj-ptrn-prop-obj-init.js | 70 ++++++++++++++ ...func-dstr-const-async-obj-ptrn-prop-obj.js | 68 +++++++++++++ ...c-dstr-const-async-obj-ptrn-rest-getter.js | 62 ++++++++++++ ...tr-const-async-obj-ptrn-rest-nested-obj.js | 59 ++++++++++++ ...nst-async-obj-ptrn-rest-obj-nested-rest.js | 69 ++++++++++++++ ...st-async-obj-ptrn-rest-obj-own-property.js | 60 ++++++++++++ ...async-obj-ptrn-rest-skip-non-enumerable.js | 68 +++++++++++++ ...-dstr-const-async-obj-ptrn-rest-val-obj.js | 67 +++++++++++++ ...func-dstr-let-async-ary-init-iter-close.js | 77 +++++++++++++++ ...c-dstr-let-async-ary-init-iter-no-close.js | 77 +++++++++++++++ ...c-func-dstr-let-async-ary-name-iter-val.js | 76 +++++++++++++++ ...r-let-async-ary-ptrn-elem-ary-elem-init.js | 68 +++++++++++++ ...r-let-async-ary-ptrn-elem-ary-elem-iter.js | 69 ++++++++++++++ ...et-async-ary-ptrn-elem-ary-elision-init.js | 75 +++++++++++++++ ...et-async-ary-ptrn-elem-ary-elision-iter.js | 72 ++++++++++++++ ...-let-async-ary-ptrn-elem-ary-empty-init.js | 70 ++++++++++++++ ...-let-async-ary-ptrn-elem-ary-empty-iter.js | 68 +++++++++++++ ...r-let-async-ary-ptrn-elem-ary-rest-init.js | 72 ++++++++++++++ ...r-let-async-ary-ptrn-elem-ary-rest-iter.js | 75 +++++++++++++++ ...t-async-ary-ptrn-elem-id-init-exhausted.js | 67 +++++++++++++ ...ync-ary-ptrn-elem-id-init-fn-name-arrow.js | 68 +++++++++++++ ...ync-ary-ptrn-elem-id-init-fn-name-class.js | 70 ++++++++++++++ ...ync-ary-ptrn-elem-id-init-fn-name-cover.js | 69 ++++++++++++++ ...-async-ary-ptrn-elem-id-init-fn-name-fn.js | 69 ++++++++++++++ ...async-ary-ptrn-elem-id-init-fn-name-gen.js | 69 ++++++++++++++ ...tr-let-async-ary-ptrn-elem-id-init-hole.js | 63 ++++++++++++ ...let-async-ary-ptrn-elem-id-init-skipped.js | 72 ++++++++++++++ ...r-let-async-ary-ptrn-elem-id-init-undef.js | 66 +++++++++++++ ...et-async-ary-ptrn-elem-id-iter-complete.js | 70 ++++++++++++++ ...tr-let-async-ary-ptrn-elem-id-iter-done.js | 65 +++++++++++++ ...str-let-async-ary-ptrn-elem-id-iter-val.js | 76 +++++++++++++++ ...str-let-async-ary-ptrn-elem-obj-id-init.js | 68 +++++++++++++ ...unc-dstr-let-async-ary-ptrn-elem-obj-id.js | 68 +++++++++++++ ...et-async-ary-ptrn-elem-obj-prop-id-init.js | 78 +++++++++++++++ ...str-let-async-ary-ptrn-elem-obj-prop-id.js | 78 +++++++++++++++ ...tr-let-async-ary-ptrn-elision-exhausted.js | 73 ++++++++++++++ ...nc-func-dstr-let-async-ary-ptrn-elision.js | 82 ++++++++++++++++ ...sync-func-dstr-let-async-ary-ptrn-empty.js | 65 +++++++++++++ ...c-dstr-let-async-ary-ptrn-rest-ary-elem.js | 89 +++++++++++++++++ ...str-let-async-ary-ptrn-rest-ary-elision.js | 95 +++++++++++++++++++ ...-dstr-let-async-ary-ptrn-rest-ary-empty.js | 78 +++++++++++++++ ...c-dstr-let-async-ary-ptrn-rest-ary-rest.js | 74 +++++++++++++++ ...dstr-let-async-ary-ptrn-rest-id-elision.js | 70 ++++++++++++++ ...tr-let-async-ary-ptrn-rest-id-exhausted.js | 66 +++++++++++++ ...nc-func-dstr-let-async-ary-ptrn-rest-id.js | 67 +++++++++++++ ...c-dstr-let-async-ary-ptrn-rest-init-ary.js | 63 ++++++++++++ ...nc-dstr-let-async-ary-ptrn-rest-init-id.js | 63 ++++++++++++ ...c-dstr-let-async-ary-ptrn-rest-init-obj.js | 63 ++++++++++++ ...r-let-async-ary-ptrn-rest-not-final-ary.js | 63 ++++++++++++ ...tr-let-async-ary-ptrn-rest-not-final-id.js | 63 ++++++++++++ ...r-let-async-ary-ptrn-rest-not-final-obj.js | 63 ++++++++++++ ...unc-dstr-let-async-ary-ptrn-rest-obj-id.js | 67 +++++++++++++ ...str-let-async-ary-ptrn-rest-obj-prop-id.js | 74 +++++++++++++++ ...sync-func-dstr-let-async-obj-ptrn-empty.js | 66 +++++++++++++ ...et-async-obj-ptrn-id-init-fn-name-arrow.js | 67 +++++++++++++ ...et-async-obj-ptrn-id-init-fn-name-class.js | 69 ++++++++++++++ ...et-async-obj-ptrn-id-init-fn-name-cover.js | 68 +++++++++++++ ...r-let-async-obj-ptrn-id-init-fn-name-fn.js | 68 +++++++++++++ ...-let-async-obj-ptrn-id-init-fn-name-gen.js | 68 +++++++++++++ ...dstr-let-async-obj-ptrn-id-init-skipped.js | 71 ++++++++++++++ ...tr-let-async-obj-ptrn-id-trailing-comma.js | 61 ++++++++++++ ...c-dstr-let-async-obj-ptrn-prop-ary-init.js | 70 ++++++++++++++ ...-async-obj-ptrn-prop-ary-trailing-comma.js | 61 ++++++++++++ ...c-func-dstr-let-async-obj-ptrn-prop-ary.js | 68 +++++++++++++ ...let-async-obj-ptrn-prop-id-init-skipped.js | 83 ++++++++++++++++ ...nc-dstr-let-async-obj-ptrn-prop-id-init.js | 64 +++++++++++++ ...t-async-obj-ptrn-prop-id-trailing-comma.js | 65 +++++++++++++ ...nc-func-dstr-let-async-obj-ptrn-prop-id.js | 64 +++++++++++++ ...c-dstr-let-async-obj-ptrn-prop-obj-init.js | 70 ++++++++++++++ ...c-func-dstr-let-async-obj-ptrn-prop-obj.js | 68 +++++++++++++ ...unc-dstr-let-async-obj-ptrn-rest-getter.js | 62 ++++++++++++ ...dstr-let-async-obj-ptrn-rest-nested-obj.js | 59 ++++++++++++ ...let-async-obj-ptrn-rest-obj-nested-rest.js | 69 ++++++++++++++ ...et-async-obj-ptrn-rest-obj-own-property.js | 60 ++++++++++++ ...async-obj-ptrn-rest-skip-non-enumerable.js | 68 +++++++++++++ ...nc-dstr-let-async-obj-ptrn-rest-val-obj.js | 67 +++++++++++++ ...func-dstr-var-async-ary-init-iter-close.js | 77 +++++++++++++++ ...c-dstr-var-async-ary-init-iter-no-close.js | 77 +++++++++++++++ ...c-func-dstr-var-async-ary-name-iter-val.js | 76 +++++++++++++++ ...r-var-async-ary-ptrn-elem-ary-elem-init.js | 68 +++++++++++++ ...r-var-async-ary-ptrn-elem-ary-elem-iter.js | 69 ++++++++++++++ ...ar-async-ary-ptrn-elem-ary-elision-init.js | 75 +++++++++++++++ ...ar-async-ary-ptrn-elem-ary-elision-iter.js | 72 ++++++++++++++ ...-var-async-ary-ptrn-elem-ary-empty-init.js | 70 ++++++++++++++ ...-var-async-ary-ptrn-elem-ary-empty-iter.js | 68 +++++++++++++ ...r-var-async-ary-ptrn-elem-ary-rest-init.js | 72 ++++++++++++++ ...r-var-async-ary-ptrn-elem-ary-rest-iter.js | 75 +++++++++++++++ ...r-async-ary-ptrn-elem-id-init-exhausted.js | 67 +++++++++++++ ...ync-ary-ptrn-elem-id-init-fn-name-arrow.js | 68 +++++++++++++ ...ync-ary-ptrn-elem-id-init-fn-name-class.js | 70 ++++++++++++++ ...ync-ary-ptrn-elem-id-init-fn-name-cover.js | 69 ++++++++++++++ ...-async-ary-ptrn-elem-id-init-fn-name-fn.js | 69 ++++++++++++++ ...async-ary-ptrn-elem-id-init-fn-name-gen.js | 69 ++++++++++++++ ...tr-var-async-ary-ptrn-elem-id-init-hole.js | 63 ++++++++++++ ...var-async-ary-ptrn-elem-id-init-skipped.js | 72 ++++++++++++++ ...r-var-async-ary-ptrn-elem-id-init-undef.js | 66 +++++++++++++ ...ar-async-ary-ptrn-elem-id-iter-complete.js | 70 ++++++++++++++ ...tr-var-async-ary-ptrn-elem-id-iter-done.js | 65 +++++++++++++ ...str-var-async-ary-ptrn-elem-id-iter-val.js | 76 +++++++++++++++ ...str-var-async-ary-ptrn-elem-obj-id-init.js | 68 +++++++++++++ ...unc-dstr-var-async-ary-ptrn-elem-obj-id.js | 68 +++++++++++++ ...ar-async-ary-ptrn-elem-obj-prop-id-init.js | 78 +++++++++++++++ ...str-var-async-ary-ptrn-elem-obj-prop-id.js | 78 +++++++++++++++ ...tr-var-async-ary-ptrn-elision-exhausted.js | 73 ++++++++++++++ ...nc-func-dstr-var-async-ary-ptrn-elision.js | 82 ++++++++++++++++ ...sync-func-dstr-var-async-ary-ptrn-empty.js | 65 +++++++++++++ ...c-dstr-var-async-ary-ptrn-rest-ary-elem.js | 89 +++++++++++++++++ ...str-var-async-ary-ptrn-rest-ary-elision.js | 95 +++++++++++++++++++ ...-dstr-var-async-ary-ptrn-rest-ary-empty.js | 78 +++++++++++++++ ...c-dstr-var-async-ary-ptrn-rest-ary-rest.js | 74 +++++++++++++++ ...dstr-var-async-ary-ptrn-rest-id-elision.js | 70 ++++++++++++++ ...tr-var-async-ary-ptrn-rest-id-exhausted.js | 66 +++++++++++++ ...nc-func-dstr-var-async-ary-ptrn-rest-id.js | 67 +++++++++++++ ...c-dstr-var-async-ary-ptrn-rest-init-ary.js | 63 ++++++++++++ ...nc-dstr-var-async-ary-ptrn-rest-init-id.js | 63 ++++++++++++ ...c-dstr-var-async-ary-ptrn-rest-init-obj.js | 63 ++++++++++++ ...r-var-async-ary-ptrn-rest-not-final-ary.js | 63 ++++++++++++ ...tr-var-async-ary-ptrn-rest-not-final-id.js | 63 ++++++++++++ ...r-var-async-ary-ptrn-rest-not-final-obj.js | 63 ++++++++++++ ...unc-dstr-var-async-ary-ptrn-rest-obj-id.js | 67 +++++++++++++ ...str-var-async-ary-ptrn-rest-obj-prop-id.js | 74 +++++++++++++++ ...sync-func-dstr-var-async-obj-ptrn-empty.js | 66 +++++++++++++ ...ar-async-obj-ptrn-id-init-fn-name-arrow.js | 67 +++++++++++++ ...ar-async-obj-ptrn-id-init-fn-name-class.js | 69 ++++++++++++++ ...ar-async-obj-ptrn-id-init-fn-name-cover.js | 68 +++++++++++++ ...r-var-async-obj-ptrn-id-init-fn-name-fn.js | 68 +++++++++++++ ...-var-async-obj-ptrn-id-init-fn-name-gen.js | 68 +++++++++++++ ...dstr-var-async-obj-ptrn-id-init-skipped.js | 71 ++++++++++++++ ...tr-var-async-obj-ptrn-id-trailing-comma.js | 61 ++++++++++++ ...c-dstr-var-async-obj-ptrn-prop-ary-init.js | 70 ++++++++++++++ ...-async-obj-ptrn-prop-ary-trailing-comma.js | 61 ++++++++++++ ...c-func-dstr-var-async-obj-ptrn-prop-ary.js | 68 +++++++++++++ ...var-async-obj-ptrn-prop-id-init-skipped.js | 83 ++++++++++++++++ ...nc-dstr-var-async-obj-ptrn-prop-id-init.js | 64 +++++++++++++ ...r-async-obj-ptrn-prop-id-trailing-comma.js | 65 +++++++++++++ ...nc-func-dstr-var-async-obj-ptrn-prop-id.js | 64 +++++++++++++ ...c-dstr-var-async-obj-ptrn-prop-obj-init.js | 70 ++++++++++++++ ...c-func-dstr-var-async-obj-ptrn-prop-obj.js | 68 +++++++++++++ ...unc-dstr-var-async-obj-ptrn-rest-getter.js | 62 ++++++++++++ ...dstr-var-async-obj-ptrn-rest-nested-obj.js | 59 ++++++++++++ ...var-async-obj-ptrn-rest-obj-nested-rest.js | 69 ++++++++++++++ ...ar-async-obj-ptrn-rest-obj-own-property.js | 60 ++++++++++++ ...async-obj-ptrn-rest-skip-non-enumerable.js | 68 +++++++++++++ ...nc-dstr-var-async-obj-ptrn-rest-val-obj.js | 67 +++++++++++++ ...en-dstr-const-async-ary-init-iter-close.js | 77 +++++++++++++++ ...dstr-const-async-ary-init-iter-no-close.js | 77 +++++++++++++++ ...-gen-dstr-const-async-ary-name-iter-val.js | 76 +++++++++++++++ ...const-async-ary-ptrn-elem-ary-elem-init.js | 68 +++++++++++++ ...const-async-ary-ptrn-elem-ary-elem-iter.js | 69 ++++++++++++++ ...st-async-ary-ptrn-elem-ary-elision-init.js | 75 +++++++++++++++ ...st-async-ary-ptrn-elem-ary-elision-iter.js | 72 ++++++++++++++ ...onst-async-ary-ptrn-elem-ary-empty-init.js | 70 ++++++++++++++ ...onst-async-ary-ptrn-elem-ary-empty-iter.js | 68 +++++++++++++ ...const-async-ary-ptrn-elem-ary-rest-init.js | 72 ++++++++++++++ ...const-async-ary-ptrn-elem-ary-rest-iter.js | 75 +++++++++++++++ ...t-async-ary-ptrn-elem-id-init-exhausted.js | 67 +++++++++++++ ...ync-ary-ptrn-elem-id-init-fn-name-arrow.js | 68 +++++++++++++ ...ync-ary-ptrn-elem-id-init-fn-name-class.js | 70 ++++++++++++++ ...ync-ary-ptrn-elem-id-init-fn-name-cover.js | 69 ++++++++++++++ ...-async-ary-ptrn-elem-id-init-fn-name-fn.js | 69 ++++++++++++++ ...async-ary-ptrn-elem-id-init-fn-name-gen.js | 69 ++++++++++++++ ...-const-async-ary-ptrn-elem-id-init-hole.js | 63 ++++++++++++ ...nst-async-ary-ptrn-elem-id-init-skipped.js | 72 ++++++++++++++ ...const-async-ary-ptrn-elem-id-init-undef.js | 66 +++++++++++++ ...st-async-ary-ptrn-elem-id-iter-complete.js | 70 ++++++++++++++ ...-const-async-ary-ptrn-elem-id-iter-done.js | 65 +++++++++++++ ...r-const-async-ary-ptrn-elem-id-iter-val.js | 76 +++++++++++++++ ...r-const-async-ary-ptrn-elem-obj-id-init.js | 68 +++++++++++++ ...n-dstr-const-async-ary-ptrn-elem-obj-id.js | 68 +++++++++++++ ...st-async-ary-ptrn-elem-obj-prop-id-init.js | 78 +++++++++++++++ ...r-const-async-ary-ptrn-elem-obj-prop-id.js | 78 +++++++++++++++ ...-const-async-ary-ptrn-elision-exhausted.js | 73 ++++++++++++++ ...c-gen-dstr-const-async-ary-ptrn-elision.js | 82 ++++++++++++++++ ...ync-gen-dstr-const-async-ary-ptrn-empty.js | 65 +++++++++++++ ...dstr-const-async-ary-ptrn-rest-ary-elem.js | 89 +++++++++++++++++ ...r-const-async-ary-ptrn-rest-ary-elision.js | 95 +++++++++++++++++++ ...str-const-async-ary-ptrn-rest-ary-empty.js | 78 +++++++++++++++ ...dstr-const-async-ary-ptrn-rest-ary-rest.js | 74 +++++++++++++++ ...tr-const-async-ary-ptrn-rest-id-elision.js | 70 ++++++++++++++ ...-const-async-ary-ptrn-rest-id-exhausted.js | 66 +++++++++++++ ...c-gen-dstr-const-async-ary-ptrn-rest-id.js | 67 +++++++++++++ ...dstr-const-async-ary-ptrn-rest-init-ary.js | 63 ++++++++++++ ...-dstr-const-async-ary-ptrn-rest-init-id.js | 63 ++++++++++++ ...dstr-const-async-ary-ptrn-rest-init-obj.js | 63 ++++++++++++ ...const-async-ary-ptrn-rest-not-final-ary.js | 63 ++++++++++++ ...-const-async-ary-ptrn-rest-not-final-id.js | 63 ++++++++++++ ...const-async-ary-ptrn-rest-not-final-obj.js | 63 ++++++++++++ ...n-dstr-const-async-ary-ptrn-rest-obj-id.js | 67 +++++++++++++ ...r-const-async-ary-ptrn-rest-obj-prop-id.js | 74 +++++++++++++++ ...ync-gen-dstr-const-async-obj-ptrn-empty.js | 66 +++++++++++++ ...st-async-obj-ptrn-id-init-fn-name-arrow.js | 67 +++++++++++++ ...st-async-obj-ptrn-id-init-fn-name-class.js | 69 ++++++++++++++ ...st-async-obj-ptrn-id-init-fn-name-cover.js | 68 +++++++++++++ ...const-async-obj-ptrn-id-init-fn-name-fn.js | 68 +++++++++++++ ...onst-async-obj-ptrn-id-init-fn-name-gen.js | 68 +++++++++++++ ...tr-const-async-obj-ptrn-id-init-skipped.js | 71 ++++++++++++++ ...-const-async-obj-ptrn-id-trailing-comma.js | 61 ++++++++++++ ...dstr-const-async-obj-ptrn-prop-ary-init.js | 70 ++++++++++++++ ...-async-obj-ptrn-prop-ary-trailing-comma.js | 61 ++++++++++++ ...-gen-dstr-const-async-obj-ptrn-prop-ary.js | 68 +++++++++++++ ...nst-async-obj-ptrn-prop-id-init-skipped.js | 83 ++++++++++++++++ ...-dstr-const-async-obj-ptrn-prop-id-init.js | 64 +++++++++++++ ...t-async-obj-ptrn-prop-id-trailing-comma.js | 65 +++++++++++++ ...c-gen-dstr-const-async-obj-ptrn-prop-id.js | 64 +++++++++++++ ...dstr-const-async-obj-ptrn-prop-obj-init.js | 70 ++++++++++++++ ...-gen-dstr-const-async-obj-ptrn-prop-obj.js | 68 +++++++++++++ ...n-dstr-const-async-obj-ptrn-rest-getter.js | 62 ++++++++++++ ...tr-const-async-obj-ptrn-rest-nested-obj.js | 59 ++++++++++++ ...nst-async-obj-ptrn-rest-obj-nested-rest.js | 69 ++++++++++++++ ...st-async-obj-ptrn-rest-obj-own-property.js | 60 ++++++++++++ ...async-obj-ptrn-rest-skip-non-enumerable.js | 68 +++++++++++++ ...-dstr-const-async-obj-ptrn-rest-val-obj.js | 67 +++++++++++++ ...-gen-dstr-let-async-ary-init-iter-close.js | 77 +++++++++++++++ ...n-dstr-let-async-ary-init-iter-no-close.js | 77 +++++++++++++++ ...nc-gen-dstr-let-async-ary-name-iter-val.js | 76 +++++++++++++++ ...r-let-async-ary-ptrn-elem-ary-elem-init.js | 68 +++++++++++++ ...r-let-async-ary-ptrn-elem-ary-elem-iter.js | 69 ++++++++++++++ ...et-async-ary-ptrn-elem-ary-elision-init.js | 75 +++++++++++++++ ...et-async-ary-ptrn-elem-ary-elision-iter.js | 72 ++++++++++++++ ...-let-async-ary-ptrn-elem-ary-empty-init.js | 70 ++++++++++++++ ...-let-async-ary-ptrn-elem-ary-empty-iter.js | 68 +++++++++++++ ...r-let-async-ary-ptrn-elem-ary-rest-init.js | 72 ++++++++++++++ ...r-let-async-ary-ptrn-elem-ary-rest-iter.js | 75 +++++++++++++++ ...t-async-ary-ptrn-elem-id-init-exhausted.js | 67 +++++++++++++ ...ync-ary-ptrn-elem-id-init-fn-name-arrow.js | 68 +++++++++++++ ...ync-ary-ptrn-elem-id-init-fn-name-class.js | 70 ++++++++++++++ ...ync-ary-ptrn-elem-id-init-fn-name-cover.js | 69 ++++++++++++++ ...-async-ary-ptrn-elem-id-init-fn-name-fn.js | 69 ++++++++++++++ ...async-ary-ptrn-elem-id-init-fn-name-gen.js | 69 ++++++++++++++ ...tr-let-async-ary-ptrn-elem-id-init-hole.js | 63 ++++++++++++ ...let-async-ary-ptrn-elem-id-init-skipped.js | 72 ++++++++++++++ ...r-let-async-ary-ptrn-elem-id-init-undef.js | 66 +++++++++++++ ...et-async-ary-ptrn-elem-id-iter-complete.js | 70 ++++++++++++++ ...tr-let-async-ary-ptrn-elem-id-iter-done.js | 65 +++++++++++++ ...str-let-async-ary-ptrn-elem-id-iter-val.js | 76 +++++++++++++++ ...str-let-async-ary-ptrn-elem-obj-id-init.js | 68 +++++++++++++ ...gen-dstr-let-async-ary-ptrn-elem-obj-id.js | 68 +++++++++++++ ...et-async-ary-ptrn-elem-obj-prop-id-init.js | 78 +++++++++++++++ ...str-let-async-ary-ptrn-elem-obj-prop-id.js | 78 +++++++++++++++ ...tr-let-async-ary-ptrn-elision-exhausted.js | 73 ++++++++++++++ ...ync-gen-dstr-let-async-ary-ptrn-elision.js | 82 ++++++++++++++++ ...async-gen-dstr-let-async-ary-ptrn-empty.js | 65 +++++++++++++ ...n-dstr-let-async-ary-ptrn-rest-ary-elem.js | 89 +++++++++++++++++ ...str-let-async-ary-ptrn-rest-ary-elision.js | 95 +++++++++++++++++++ ...-dstr-let-async-ary-ptrn-rest-ary-empty.js | 78 +++++++++++++++ ...n-dstr-let-async-ary-ptrn-rest-ary-rest.js | 74 +++++++++++++++ ...dstr-let-async-ary-ptrn-rest-id-elision.js | 70 ++++++++++++++ ...tr-let-async-ary-ptrn-rest-id-exhausted.js | 66 +++++++++++++ ...ync-gen-dstr-let-async-ary-ptrn-rest-id.js | 67 +++++++++++++ ...n-dstr-let-async-ary-ptrn-rest-init-ary.js | 63 ++++++++++++ ...en-dstr-let-async-ary-ptrn-rest-init-id.js | 63 ++++++++++++ ...n-dstr-let-async-ary-ptrn-rest-init-obj.js | 63 ++++++++++++ ...r-let-async-ary-ptrn-rest-not-final-ary.js | 63 ++++++++++++ ...tr-let-async-ary-ptrn-rest-not-final-id.js | 63 ++++++++++++ ...r-let-async-ary-ptrn-rest-not-final-obj.js | 63 ++++++++++++ ...gen-dstr-let-async-ary-ptrn-rest-obj-id.js | 67 +++++++++++++ ...str-let-async-ary-ptrn-rest-obj-prop-id.js | 74 +++++++++++++++ ...async-gen-dstr-let-async-obj-ptrn-empty.js | 66 +++++++++++++ ...et-async-obj-ptrn-id-init-fn-name-arrow.js | 67 +++++++++++++ ...et-async-obj-ptrn-id-init-fn-name-class.js | 69 ++++++++++++++ ...et-async-obj-ptrn-id-init-fn-name-cover.js | 68 +++++++++++++ ...r-let-async-obj-ptrn-id-init-fn-name-fn.js | 68 +++++++++++++ ...-let-async-obj-ptrn-id-init-fn-name-gen.js | 68 +++++++++++++ ...dstr-let-async-obj-ptrn-id-init-skipped.js | 71 ++++++++++++++ ...tr-let-async-obj-ptrn-id-trailing-comma.js | 61 ++++++++++++ ...n-dstr-let-async-obj-ptrn-prop-ary-init.js | 70 ++++++++++++++ ...-async-obj-ptrn-prop-ary-trailing-comma.js | 61 ++++++++++++ ...nc-gen-dstr-let-async-obj-ptrn-prop-ary.js | 68 +++++++++++++ ...let-async-obj-ptrn-prop-id-init-skipped.js | 83 ++++++++++++++++ ...en-dstr-let-async-obj-ptrn-prop-id-init.js | 64 +++++++++++++ ...t-async-obj-ptrn-prop-id-trailing-comma.js | 65 +++++++++++++ ...ync-gen-dstr-let-async-obj-ptrn-prop-id.js | 64 +++++++++++++ ...n-dstr-let-async-obj-ptrn-prop-obj-init.js | 70 ++++++++++++++ ...nc-gen-dstr-let-async-obj-ptrn-prop-obj.js | 68 +++++++++++++ ...gen-dstr-let-async-obj-ptrn-rest-getter.js | 62 ++++++++++++ ...dstr-let-async-obj-ptrn-rest-nested-obj.js | 59 ++++++++++++ ...let-async-obj-ptrn-rest-obj-nested-rest.js | 69 ++++++++++++++ ...et-async-obj-ptrn-rest-obj-own-property.js | 60 ++++++++++++ ...async-obj-ptrn-rest-skip-non-enumerable.js | 68 +++++++++++++ ...en-dstr-let-async-obj-ptrn-rest-val-obj.js | 67 +++++++++++++ ...-gen-dstr-var-async-ary-init-iter-close.js | 77 +++++++++++++++ ...n-dstr-var-async-ary-init-iter-no-close.js | 77 +++++++++++++++ ...nc-gen-dstr-var-async-ary-name-iter-val.js | 76 +++++++++++++++ ...r-var-async-ary-ptrn-elem-ary-elem-init.js | 68 +++++++++++++ ...r-var-async-ary-ptrn-elem-ary-elem-iter.js | 69 ++++++++++++++ ...ar-async-ary-ptrn-elem-ary-elision-init.js | 75 +++++++++++++++ ...ar-async-ary-ptrn-elem-ary-elision-iter.js | 72 ++++++++++++++ ...-var-async-ary-ptrn-elem-ary-empty-init.js | 70 ++++++++++++++ ...-var-async-ary-ptrn-elem-ary-empty-iter.js | 68 +++++++++++++ ...r-var-async-ary-ptrn-elem-ary-rest-init.js | 72 ++++++++++++++ ...r-var-async-ary-ptrn-elem-ary-rest-iter.js | 75 +++++++++++++++ ...r-async-ary-ptrn-elem-id-init-exhausted.js | 67 +++++++++++++ ...ync-ary-ptrn-elem-id-init-fn-name-arrow.js | 68 +++++++++++++ ...ync-ary-ptrn-elem-id-init-fn-name-class.js | 70 ++++++++++++++ ...ync-ary-ptrn-elem-id-init-fn-name-cover.js | 69 ++++++++++++++ ...-async-ary-ptrn-elem-id-init-fn-name-fn.js | 69 ++++++++++++++ ...async-ary-ptrn-elem-id-init-fn-name-gen.js | 69 ++++++++++++++ ...tr-var-async-ary-ptrn-elem-id-init-hole.js | 63 ++++++++++++ ...var-async-ary-ptrn-elem-id-init-skipped.js | 72 ++++++++++++++ ...r-var-async-ary-ptrn-elem-id-init-undef.js | 66 +++++++++++++ ...ar-async-ary-ptrn-elem-id-iter-complete.js | 70 ++++++++++++++ ...tr-var-async-ary-ptrn-elem-id-iter-done.js | 65 +++++++++++++ ...str-var-async-ary-ptrn-elem-id-iter-val.js | 76 +++++++++++++++ ...str-var-async-ary-ptrn-elem-obj-id-init.js | 68 +++++++++++++ ...gen-dstr-var-async-ary-ptrn-elem-obj-id.js | 68 +++++++++++++ ...ar-async-ary-ptrn-elem-obj-prop-id-init.js | 78 +++++++++++++++ ...str-var-async-ary-ptrn-elem-obj-prop-id.js | 78 +++++++++++++++ ...tr-var-async-ary-ptrn-elision-exhausted.js | 73 ++++++++++++++ ...ync-gen-dstr-var-async-ary-ptrn-elision.js | 82 ++++++++++++++++ ...async-gen-dstr-var-async-ary-ptrn-empty.js | 65 +++++++++++++ ...n-dstr-var-async-ary-ptrn-rest-ary-elem.js | 89 +++++++++++++++++ ...str-var-async-ary-ptrn-rest-ary-elision.js | 95 +++++++++++++++++++ ...-dstr-var-async-ary-ptrn-rest-ary-empty.js | 78 +++++++++++++++ ...n-dstr-var-async-ary-ptrn-rest-ary-rest.js | 74 +++++++++++++++ ...dstr-var-async-ary-ptrn-rest-id-elision.js | 70 ++++++++++++++ ...tr-var-async-ary-ptrn-rest-id-exhausted.js | 66 +++++++++++++ ...ync-gen-dstr-var-async-ary-ptrn-rest-id.js | 67 +++++++++++++ ...n-dstr-var-async-ary-ptrn-rest-init-ary.js | 63 ++++++++++++ ...en-dstr-var-async-ary-ptrn-rest-init-id.js | 63 ++++++++++++ ...n-dstr-var-async-ary-ptrn-rest-init-obj.js | 63 ++++++++++++ ...r-var-async-ary-ptrn-rest-not-final-ary.js | 63 ++++++++++++ ...tr-var-async-ary-ptrn-rest-not-final-id.js | 63 ++++++++++++ ...r-var-async-ary-ptrn-rest-not-final-obj.js | 63 ++++++++++++ ...gen-dstr-var-async-ary-ptrn-rest-obj-id.js | 67 +++++++++++++ ...str-var-async-ary-ptrn-rest-obj-prop-id.js | 74 +++++++++++++++ ...async-gen-dstr-var-async-obj-ptrn-empty.js | 66 +++++++++++++ ...ar-async-obj-ptrn-id-init-fn-name-arrow.js | 67 +++++++++++++ ...ar-async-obj-ptrn-id-init-fn-name-class.js | 69 ++++++++++++++ ...ar-async-obj-ptrn-id-init-fn-name-cover.js | 68 +++++++++++++ ...r-var-async-obj-ptrn-id-init-fn-name-fn.js | 68 +++++++++++++ ...-var-async-obj-ptrn-id-init-fn-name-gen.js | 68 +++++++++++++ ...dstr-var-async-obj-ptrn-id-init-skipped.js | 71 ++++++++++++++ ...tr-var-async-obj-ptrn-id-trailing-comma.js | 61 ++++++++++++ ...n-dstr-var-async-obj-ptrn-prop-ary-init.js | 70 ++++++++++++++ ...-async-obj-ptrn-prop-ary-trailing-comma.js | 61 ++++++++++++ ...nc-gen-dstr-var-async-obj-ptrn-prop-ary.js | 68 +++++++++++++ ...var-async-obj-ptrn-prop-id-init-skipped.js | 83 ++++++++++++++++ ...en-dstr-var-async-obj-ptrn-prop-id-init.js | 64 +++++++++++++ ...r-async-obj-ptrn-prop-id-trailing-comma.js | 65 +++++++++++++ ...ync-gen-dstr-var-async-obj-ptrn-prop-id.js | 64 +++++++++++++ ...n-dstr-var-async-obj-ptrn-prop-obj-init.js | 70 ++++++++++++++ ...nc-gen-dstr-var-async-obj-ptrn-prop-obj.js | 68 +++++++++++++ ...gen-dstr-var-async-obj-ptrn-rest-getter.js | 62 ++++++++++++ ...dstr-var-async-obj-ptrn-rest-nested-obj.js | 59 ++++++++++++ ...var-async-obj-ptrn-rest-obj-nested-rest.js | 69 ++++++++++++++ ...ar-async-obj-ptrn-rest-obj-own-property.js | 60 ++++++++++++ ...async-obj-ptrn-rest-skip-non-enumerable.js | 68 +++++++++++++ ...en-dstr-var-async-obj-ptrn-rest-val-obj.js | 67 +++++++++++++ 408 files changed, 28374 insertions(+) create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-async-ary-init-iter-close.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-async-ary-init-iter-no-close.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-async-ary-name-iter-val.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-ary-elem-init.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-ary-elem-iter.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-ary-elision-init.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-ary-elision-iter.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-ary-empty-init.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-ary-empty-iter.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-ary-rest-init.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-ary-rest-iter.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-init-exhausted.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-init-fn-name-arrow.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-init-fn-name-class.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-init-fn-name-cover.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-init-fn-name-fn.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-init-fn-name-gen.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-init-hole.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-init-skipped.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-init-undef.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-iter-complete.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-iter-done.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-iter-val.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-obj-id-init.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-obj-id.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-obj-prop-id-init.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-obj-prop-id.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elision-exhausted.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elision.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-empty.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-ary-elem.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-ary-elision.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-ary-empty.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-ary-rest.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-id-elision.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-id-exhausted.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-id.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-init-ary.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-init-id.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-init-obj.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-not-final-ary.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-not-final-id.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-not-final-obj.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-obj-id.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-obj-prop-id.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-empty.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-id-init-fn-name-arrow.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-id-init-fn-name-class.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-id-init-fn-name-cover.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-id-init-fn-name-fn.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-id-init-fn-name-gen.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-id-init-skipped.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-id-trailing-comma.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-prop-ary-init.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-prop-ary-trailing-comma.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-prop-ary.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-prop-id-init-skipped.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-prop-id-init.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-prop-id-trailing-comma.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-prop-id.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-prop-obj-init.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-prop-obj.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-rest-getter.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-rest-nested-obj.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-rest-obj-nested-rest.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-rest-obj-own-property.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-rest-skip-non-enumerable.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-rest-val-obj.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-async-ary-init-iter-close.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-async-ary-init-iter-no-close.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-async-ary-name-iter-val.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-ary-elem-init.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-ary-elem-iter.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-ary-elision-init.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-ary-elision-iter.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-ary-empty-init.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-ary-empty-iter.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-ary-rest-init.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-ary-rest-iter.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-init-exhausted.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-init-fn-name-arrow.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-init-fn-name-class.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-init-fn-name-cover.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-init-fn-name-fn.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-init-fn-name-gen.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-init-hole.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-init-skipped.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-init-undef.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-iter-complete.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-iter-done.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-iter-val.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-obj-id-init.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-obj-id.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-obj-prop-id-init.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-obj-prop-id.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elision-exhausted.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elision.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-empty.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-ary-elem.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-ary-elision.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-ary-empty.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-ary-rest.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-id-elision.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-id-exhausted.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-id.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-init-ary.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-init-id.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-init-obj.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-not-final-ary.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-not-final-id.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-not-final-obj.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-obj-id.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-obj-prop-id.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-empty.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-id-init-fn-name-arrow.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-id-init-fn-name-class.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-id-init-fn-name-cover.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-id-init-fn-name-fn.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-id-init-fn-name-gen.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-id-init-skipped.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-id-trailing-comma.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-prop-ary-init.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-prop-ary-trailing-comma.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-prop-ary.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-prop-id-init-skipped.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-prop-id-init.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-prop-id-trailing-comma.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-prop-id.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-prop-obj-init.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-prop-obj.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-rest-getter.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-rest-nested-obj.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-rest-obj-nested-rest.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-rest-obj-own-property.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-rest-skip-non-enumerable.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-rest-val-obj.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-async-ary-init-iter-close.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-async-ary-init-iter-no-close.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-async-ary-name-iter-val.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-ary-elem-init.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-ary-elem-iter.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-ary-elision-init.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-ary-elision-iter.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-ary-empty-init.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-ary-empty-iter.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-ary-rest-init.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-ary-rest-iter.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-init-exhausted.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-init-fn-name-arrow.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-init-fn-name-class.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-init-fn-name-cover.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-init-fn-name-fn.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-init-fn-name-gen.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-init-hole.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-init-skipped.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-init-undef.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-iter-complete.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-iter-done.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-iter-val.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-obj-id-init.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-obj-id.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-obj-prop-id-init.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-obj-prop-id.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elision-exhausted.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elision.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-empty.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-ary-elem.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-ary-elision.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-ary-empty.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-ary-rest.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-id-elision.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-id-exhausted.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-id.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-init-ary.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-init-id.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-init-obj.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-not-final-ary.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-not-final-id.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-not-final-obj.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-obj-id.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-obj-prop-id.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-empty.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-id-init-fn-name-arrow.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-id-init-fn-name-class.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-id-init-fn-name-cover.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-id-init-fn-name-fn.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-id-init-fn-name-gen.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-id-init-skipped.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-id-trailing-comma.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-prop-ary-init.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-prop-ary-trailing-comma.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-prop-ary.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-prop-id-init-skipped.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-prop-id-init.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-prop-id-trailing-comma.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-prop-id.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-prop-obj-init.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-prop-obj.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-rest-getter.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-rest-nested-obj.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-rest-obj-nested-rest.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-rest-obj-own-property.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-rest-skip-non-enumerable.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-rest-val-obj.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-async-ary-init-iter-close.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-async-ary-init-iter-no-close.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-async-ary-name-iter-val.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-ary-elem-init.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-ary-elem-iter.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-ary-elision-init.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-ary-elision-iter.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-ary-empty-init.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-ary-empty-iter.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-ary-rest-init.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-ary-rest-iter.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-init-exhausted.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-init-fn-name-arrow.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-init-fn-name-class.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-init-fn-name-cover.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-init-fn-name-fn.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-init-fn-name-gen.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-init-hole.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-init-skipped.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-init-undef.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-iter-complete.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-iter-done.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-iter-val.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-obj-id-init.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-obj-id.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-obj-prop-id-init.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-obj-prop-id.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elision-exhausted.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elision.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-empty.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-ary-elem.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-ary-elision.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-ary-empty.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-ary-rest.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-id-elision.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-id-exhausted.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-id.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-init-ary.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-init-id.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-init-obj.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-not-final-ary.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-not-final-id.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-not-final-obj.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-obj-id.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-obj-prop-id.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-empty.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-id-init-fn-name-arrow.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-id-init-fn-name-class.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-id-init-fn-name-cover.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-id-init-fn-name-fn.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-id-init-fn-name-gen.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-id-init-skipped.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-id-trailing-comma.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-prop-ary-init.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-prop-ary-trailing-comma.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-prop-ary.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-prop-id-init-skipped.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-prop-id-init.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-prop-id-trailing-comma.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-prop-id.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-prop-obj-init.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-prop-obj.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-rest-getter.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-rest-nested-obj.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-rest-obj-nested-rest.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-rest-obj-own-property.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-rest-skip-non-enumerable.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-rest-val-obj.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-async-ary-init-iter-close.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-async-ary-init-iter-no-close.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-async-ary-name-iter-val.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-ary-elem-init.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-ary-elem-iter.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-ary-elision-init.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-ary-elision-iter.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-ary-empty-init.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-ary-empty-iter.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-ary-rest-init.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-ary-rest-iter.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-init-exhausted.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-init-fn-name-arrow.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-init-fn-name-class.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-init-fn-name-cover.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-init-fn-name-fn.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-init-fn-name-gen.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-init-hole.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-init-skipped.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-init-undef.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-iter-complete.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-iter-done.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-iter-val.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-obj-id-init.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-obj-id.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-obj-prop-id-init.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-obj-prop-id.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elision-exhausted.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elision.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-empty.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-ary-elem.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-ary-elision.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-ary-empty.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-ary-rest.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-id-elision.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-id-exhausted.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-id.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-init-ary.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-init-id.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-init-obj.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-not-final-ary.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-not-final-id.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-not-final-obj.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-obj-id.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-obj-prop-id.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-empty.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-id-init-fn-name-arrow.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-id-init-fn-name-class.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-id-init-fn-name-cover.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-id-init-fn-name-fn.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-id-init-fn-name-gen.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-id-init-skipped.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-id-trailing-comma.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-prop-ary-init.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-prop-ary-trailing-comma.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-prop-ary.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-prop-id-init-skipped.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-prop-id-init.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-prop-id-trailing-comma.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-prop-id.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-prop-obj-init.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-prop-obj.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-rest-getter.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-rest-nested-obj.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-rest-obj-nested-rest.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-rest-obj-own-property.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-rest-skip-non-enumerable.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-rest-val-obj.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-async-ary-init-iter-close.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-async-ary-init-iter-no-close.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-async-ary-name-iter-val.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-ary-elem-init.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-ary-elem-iter.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-ary-elision-init.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-ary-elision-iter.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-ary-empty-init.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-ary-empty-iter.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-ary-rest-init.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-ary-rest-iter.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-init-exhausted.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-init-fn-name-arrow.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-init-fn-name-class.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-init-fn-name-cover.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-init-fn-name-fn.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-init-fn-name-gen.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-init-hole.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-init-skipped.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-init-undef.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-iter-complete.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-iter-done.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-iter-val.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-obj-id-init.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-obj-id.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-obj-prop-id-init.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-obj-prop-id.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elision-exhausted.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elision.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-empty.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-ary-elem.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-ary-elision.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-ary-empty.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-ary-rest.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-id-elision.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-id-exhausted.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-id.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-init-ary.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-init-id.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-init-obj.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-not-final-ary.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-not-final-id.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-not-final-obj.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-obj-id.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-obj-prop-id.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-empty.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-id-init-fn-name-arrow.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-id-init-fn-name-class.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-id-init-fn-name-cover.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-id-init-fn-name-fn.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-id-init-fn-name-gen.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-id-init-skipped.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-id-trailing-comma.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-prop-ary-init.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-prop-ary-trailing-comma.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-prop-ary.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-prop-id-init-skipped.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-prop-id-init.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-prop-id-trailing-comma.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-prop-id.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-prop-obj-init.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-prop-obj.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-rest-getter.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-rest-nested-obj.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-rest-obj-nested-rest.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-rest-obj-own-property.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-rest-skip-non-enumerable.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-rest-val-obj.js diff --git a/test/language/statements/for-await-of/async-func-dstr-const-async-ary-init-iter-close.js b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-init-iter-close.js new file mode 100644 index 0000000000..eba337271a --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-init-iter-close.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-close.case +// - src/dstr-binding/default/for-await-of-async-func-const-async.template +/*--- +description: Iterator is closed when not exhausted by pattern evaluation (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [Symbol.iterator, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: false }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [iter]; +})(); + +async function fn() { + for await (const [x] of asyncIter) { + assert.sameValue(doneCallCount, 1); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-const-async-ary-init-iter-no-close.js b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-init-iter-no-close.js new file mode 100644 index 0000000000..0dfc920caa --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-init-iter-no-close.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-no-close.case +// - src/dstr-binding/default/for-await-of-async-func-const-async.template +/*--- +description: Iterator is not closed when exhausted by pattern evaluation (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [Symbol.iterator, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: true }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [iter]; +})(); + +async function fn() { + for await (const [x] of asyncIter) { + assert.sameValue(doneCallCount, 0); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-const-async-ary-name-iter-val.js b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-name-iter-val.js new file mode 100644 index 0000000000..c6e4588bb9 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-name-iter-val.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-name-iter-val.case +// - src/dstr-binding/default/for-await-of-async-func-const-async.template +/*--- +description: SingleNameBinding with normal value iteration (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[1, 2, 3]]; +})(); + +async function fn() { + for await (const [x, y, z] of asyncIter) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-ary-elem-init.js b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-ary-elem-init.js new file mode 100644 index 0000000000..21be8c7662 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-ary-elem-init.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-init.case +// - src/dstr-binding/default/for-await-of-async-func-const-async.template +/*--- +description: BindingElement with array binding pattern and initializer is used (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function fn() { + for await (const [[x, y, z] = [4, 5, 6]] of asyncIter) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-ary-elem-iter.js b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-ary-elem-iter.js new file mode 100644 index 0000000000..64d1e65efb --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-ary-elem-iter.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-iter.case +// - src/dstr-binding/default/for-await-of-async-func-const-async.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[[7, 8, 9]]]; +})(); + +async function fn() { + for await (const [[x, y, z] = [4, 5, 6]] of asyncIter) { + assert.sameValue(x, 7); + assert.sameValue(y, 8); + assert.sameValue(z, 9); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-ary-elision-init.js b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-ary-elision-init.js new file mode 100644 index 0000000000..b008d06ec6 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-ary-elision-init.js @@ -0,0 +1,75 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case +// - src/dstr-binding/default/for-await-of-async-func-const-async.template +/*--- +description: BindingElement with array binding pattern and initializer is used (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [generators, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function fn() { + for await (const [[,] = g()] of asyncIter) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-ary-elision-iter.js b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-ary-elision-iter.js new file mode 100644 index 0000000000..7b8ad2fccf --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-ary-elision-iter.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-iter.case +// - src/dstr-binding/default/for-await-of-async-func-const-async.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [generators, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var callCount = 0; +function* g() { + callCount += 1; +}; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[[]]]; +})(); + +async function fn() { + for await (const [[,] = g()] of asyncIter) { + assert.sameValue(callCount, 0); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-ary-empty-init.js b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-ary-empty-init.js new file mode 100644 index 0000000000..a7814dc91b --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-ary-empty-init.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-init.case +// - src/dstr-binding/default/for-await-of-async-func-const-async.template +/*--- +description: BindingElement with array binding pattern and initializer is used (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; +var iterCount = 0; +var iter = function*() { iterCount += 1; }(); + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function fn() { + for await (const [[] = function() { initCount += 1; return iter; }()] of asyncIter) { + assert.sameValue(initCount, 1); + assert.sameValue(iterCount, 0); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-ary-empty-iter.js b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-ary-empty-iter.js new file mode 100644 index 0000000000..5abf021c64 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-ary-empty-iter.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-iter.case +// - src/dstr-binding/default/for-await-of-async-func-const-async.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[[23]]]; +})(); + +async function fn() { + for await (const [[] = function() { initCount += 1; }()] of asyncIter) { + assert.sameValue(initCount, 0); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-ary-rest-init.js b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-ary-rest-init.js new file mode 100644 index 0000000000..f16b0775dd --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-ary-rest-init.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-init.case +// - src/dstr-binding/default/for-await-of-async-func-const-async.template +/*--- +description: BindingElement with array binding pattern and initializer is used (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function fn() { + for await (const [[...x] = values] of asyncIter) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-ary-rest-iter.js b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-ary-rest-iter.js new file mode 100644 index 0000000000..7b85064694 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-ary-rest-iter.js @@ -0,0 +1,75 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-iter.case +// - src/dstr-binding/default/for-await-of-async-func-const-async.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; +var initCount = 0; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[values]]; +})(); + +async function fn() { + for await (const [[...x] = function() { initCount += 1; }()] of asyncIter) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + assert.sameValue(initCount, 0); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-init-exhausted.js b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-init-exhausted.js new file mode 100644 index 0000000000..744201c51f --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-init-exhausted.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-exhausted.case +// - src/dstr-binding/default/for-await-of-async-func-const-async.template +/*--- +description: Destructuring initializer with an exhausted iterator (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function fn() { + for await (const [x = 23] of asyncIter) { + assert.sameValue(x, 23); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-init-fn-name-arrow.js b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..073900accd --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-init-fn-name-arrow.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-arrow.case +// - src/dstr-binding/default/for-await-of-async-func-const-async.template +/*--- +description: SingleNameBinding does assign name to arrow functions (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function fn() { + for await (const [arrow = () => {}] of asyncIter) { + assert.sameValue(arrow.name, 'arrow'); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-init-fn-name-class.js b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-init-fn-name-class.js new file mode 100644 index 0000000000..e544004cdb --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-init-fn-name-class.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-class.case +// - src/dstr-binding/default/for-await-of-async-func-const-async.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function fn() { + for await (const [cls = class {}, xCls = class X {}, xCls2 = class { static name() {} }] of asyncIter) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + assert.notSameValue(xCls2.name, 'xCls2'); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-init-fn-name-cover.js b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-init-fn-name-cover.js new file mode 100644 index 0000000000..8ec716384b --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-init-fn-name-cover.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-cover.case +// - src/dstr-binding/default/for-await-of-async-func-const-async.template +/*--- +description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function fn() { + for await (const [cover = (function () {}), xCover = (0, function() {})] of asyncIter) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-init-fn-name-fn.js b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-init-fn-name-fn.js new file mode 100644 index 0000000000..954196eb9f --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-init-fn-name-fn.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-fn.case +// - src/dstr-binding/default/for-await-of-async-func-const-async.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function fn() { + for await (const [fn = function () {}, xFn = function x() {}] of asyncIter) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-init-fn-name-gen.js b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-init-fn-name-gen.js new file mode 100644 index 0000000000..de40d651b8 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-init-fn-name-gen.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-gen.case +// - src/dstr-binding/default/for-await-of-async-func-const-async.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function fn() { + for await (const [gen = function* () {}, xGen = function* x() {}] of asyncIter) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-init-hole.js b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-init-hole.js new file mode 100644 index 0000000000..794fa0a8e5 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-init-hole.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-hole.case +// - src/dstr-binding/default/for-await-of-async-func-const-async.template +/*--- +description: Destructuring initializer with a "hole" (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + SingleNameBinding : BindingIdentifier Initializeropt + [...] 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[,]]; +})(); + +async function fn() { + for await (const [x = 23] of asyncIter) { + assert.sameValue(x, 23); + // another statement + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-init-skipped.js b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-init-skipped.js new file mode 100644 index 0000000000..9130c6a693 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-init-skipped.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-skipped.case +// - src/dstr-binding/default/for-await-of-async-func-const-async.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[null, 0, false, '']]; +})(); + +async function fn() { + for await (const [w = counter(), x = counter(), y = counter(), z = counter()] of asyncIter) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-init-undef.js b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-init-undef.js new file mode 100644 index 0000000000..e9484712de --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-init-undef.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-undef.case +// - src/dstr-binding/default/for-await-of-async-func-const-async.template +/*--- +description: Destructuring initializer with an undefined value (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[undefined]]; +})(); + +async function fn() { + for await (const [x = 23] of asyncIter) { + assert.sameValue(x, 23); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-iter-complete.js b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-iter-complete.js new file mode 100644 index 0000000000..302e91c7f6 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-iter-complete.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-complete.case +// - src/dstr-binding/default/for-await-of-async-func-const-async.template +/*--- +description: SingleNameBinding when value iteration completes (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function fn() { + for await (const [x] of asyncIter) { + assert.sameValue(x, undefined); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-iter-done.js b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-iter-done.js new file mode 100644 index 0000000000..8120d00a8a --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-iter-done.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-done.case +// - src/dstr-binding/default/for-await-of-async-func-const-async.template +/*--- +description: SingleNameBinding when value iteration was completed previously (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function fn() { + for await (const [_, x] of asyncIter) { + assert.sameValue(x, undefined); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-iter-val.js b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-iter-val.js new file mode 100644 index 0000000000..7c3dca13ab --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-iter-val.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val.case +// - src/dstr-binding/default/for-await-of-async-func-const-async.template +/*--- +description: SingleNameBinding when value iteration was completed previously (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[1, 2, 3]]; +})(); + +async function fn() { + for await (const [x, y, z] of asyncIter) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-obj-id-init.js b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-obj-id-init.js new file mode 100644 index 0000000000..8a56b7f00f --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-obj-id-init.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id-init.case +// - src/dstr-binding/default/for-await-of-async-func-const-async.template +/*--- +description: BindingElement with object binding pattern and initializer is used (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function fn() { + for await (const [{ x, y, z } = { x: 44, y: 55, z: 66 }] of asyncIter) { + assert.sameValue(x, 44); + assert.sameValue(y, 55); + assert.sameValue(z, 66); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-obj-id.js b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-obj-id.js new file mode 100644 index 0000000000..7adfce8eed --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-obj-id.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id.case +// - src/dstr-binding/default/for-await-of-async-func-const-async.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[{ x: 11, y: 22, z: 33 }]]; +})(); + +async function fn() { + for await (const [{ x, y, z } = { x: 44, y: 55, z: 66 }] of asyncIter) { + assert.sameValue(x, 11); + assert.sameValue(y, 22); + assert.sameValue(z, 33); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-obj-prop-id-init.js b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-obj-prop-id-init.js new file mode 100644 index 0000000000..ded1f42337 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-obj-prop-id-init.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id-init.case +// - src/dstr-binding/default/for-await-of-async-func-const-async.template +/*--- +description: BindingElement with object binding pattern and initializer is used (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function fn() { + for await (const [{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] of asyncIter) { + assert.sameValue(v, 444); + assert.sameValue(x, 555); + assert.sameValue(z, 666); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-obj-prop-id.js b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-obj-prop-id.js new file mode 100644 index 0000000000..8f4be17b7f --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-obj-prop-id.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id.case +// - src/dstr-binding/default/for-await-of-async-func-const-async.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[{ u: 777, w: 888, y: 999 }]]; +})(); + +async function fn() { + for await (const [{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] of asyncIter) { + assert.sameValue(v, 777); + assert.sameValue(x, 888); + assert.sameValue(z, 999); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elision-exhausted.js b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elision-exhausted.js new file mode 100644 index 0000000000..8c1fe66550 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elision-exhausted.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-exhausted.case +// - src/dstr-binding/default/for-await-of-async-func-const-async.template +/*--- +description: Elision accepts exhausted iterator (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [generator, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + [...] + 2. Return NormalCompletion(empty). + +---*/ +var iter = function*() {}(); +iter.next(); + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [iter]; +})(); + +async function fn() { + for await (const [,] of asyncIter) { + + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elision.js b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elision.js new file mode 100644 index 0000000000..4b39ae3729 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elision.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision.case +// - src/dstr-binding/default/for-await-of-async-func-const-async.template +/*--- +description: Elision advances iterator (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [generator, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [g()]; +})(); + +async function fn() { + for await (const [,] of asyncIter) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-empty.js b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-empty.js new file mode 100644 index 0000000000..6ec277ac01 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-empty.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-empty.case +// - src/dstr-binding/default/for-await-of-async-func-const-async.template +/*--- +description: No iteration occurs for an "empty" array binding pattern (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [generators, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [iter]; +})(); + +async function fn() { + for await (const [] of asyncIter) { + assert.sameValue(iterations, 0); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-ary-elem.js b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-ary-elem.js new file mode 100644 index 0000000000..1b07b18968 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-ary-elem.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elem.case +// - src/dstr-binding/default/for-await-of-async-func-const-async.template +/*--- +description: Rest element containing an array BindingElementList pattern (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[3, 4, 5]]; +})(); + +async function fn() { + for await (const [...[x, y, z]] of asyncIter) { + assert.sameValue(x, 3); + assert.sameValue(y, 4); + assert.sameValue(z, 5); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-ary-elision.js b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-ary-elision.js new file mode 100644 index 0000000000..2b31699dcb --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-ary-elision.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elision.case +// - src/dstr-binding/default/for-await-of-async-func-const-async.template +/*--- +description: Rest element containing an elision (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [generators, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [g()]; +})(); + +async function fn() { + for await (const [...[,]] of asyncIter) { + assert.sameValue(first, 1); + assert.sameValue(second, 1); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-ary-empty.js b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-ary-empty.js new file mode 100644 index 0000000000..52510433ea --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-ary-empty.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-empty.case +// - src/dstr-binding/default/for-await-of-async-func-const-async.template +/*--- +description: Rest element containing an "empty" array pattern (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [generators, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [iter]; +})(); + +async function fn() { + for await (const [...[]] of asyncIter) { + assert.sameValue(iterations, 1); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-ary-rest.js b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-ary-rest.js new file mode 100644 index 0000000000..c4ba453373 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-ary-rest.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-rest.case +// - src/dstr-binding/default/for-await-of-async-func-const-async.template +/*--- +description: Rest element containing a rest element (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +var values = [1, 2, 3]; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [values]; +})(); + +async function fn() { + for await (const [...[...x]] of asyncIter) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-id-elision.js b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-id-elision.js new file mode 100644 index 0000000000..afb1252516 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-id-elision.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision.case +// - src/dstr-binding/default/for-await-of-async-func-const-async.template +/*--- +description: Rest element following elision elements (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. +---*/ +var values = [1, 2, 3, 4, 5]; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [values]; +})(); + +async function fn() { + for await (const [ , , ...x] of asyncIter) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 3); + assert.sameValue(x[1], 4); + assert.sameValue(x[2], 5); + assert.notSameValue(x, values); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-id-exhausted.js b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-id-exhausted.js new file mode 100644 index 0000000000..effcfc3622 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-id-exhausted.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-exhausted.case +// - src/dstr-binding/default/for-await-of-async-func-const-async.template +/*--- +description: RestElement applied to an exhausted iterator (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [Symbol.iterator, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + b. If iteratorRecord.[[done]] is true, then + i. If environment is undefined, return PutValue(lhs, A). + ii. Return InitializeReferencedBinding(lhs, A). + +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[1, 2]]; +})(); + +async function fn() { + for await (const [, , ...x] of asyncIter) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 0); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-id.js b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-id.js new file mode 100644 index 0000000000..b0cce464af --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-id.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id.case +// - src/dstr-binding/default/for-await-of-async-func-const-async.template +/*--- +description: Lone rest element (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat + [...] + f. Let status be CreateDataProperty(A, ToString (n), nextValue). + [...] +---*/ +var values = [1, 2, 3]; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [values]; +})(); + +async function fn() { + for await (const [...x] of asyncIter) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-init-ary.js b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-init-ary.js new file mode 100644 index 0000000000..5bdfcb5502 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-init-ary.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-ary.case +// - src/dstr-binding/default/for-await-of-async-func-const-async.template +/*--- +description: Reset element (nested array pattern) does not support initializer (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +negative: + phase: early + type: SyntaxError +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function fn() { + for await (const [...[ x ] = []] of asyncIter) { + + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-init-id.js b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-init-id.js new file mode 100644 index 0000000000..7b028d2279 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-init-id.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-id.case +// - src/dstr-binding/default/for-await-of-async-func-const-async.template +/*--- +description: Reset element (identifier) does not support initializer (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +negative: + phase: early + type: SyntaxError +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function fn() { + for await (const [...x = []] of asyncIter) { + + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-init-obj.js b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-init-obj.js new file mode 100644 index 0000000000..865bbf365d --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-init-obj.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-obj.case +// - src/dstr-binding/default/for-await-of-async-func-const-async.template +/*--- +description: Reset element (nested object pattern) does not support initializer (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +negative: + phase: early + type: SyntaxError +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function fn() { + for await (const [...{ x } = []] of asyncIter) { + + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-not-final-ary.js b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-not-final-ary.js new file mode 100644 index 0000000000..4110ded90f --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-not-final-ary.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-ary.case +// - src/dstr-binding/default/for-await-of-async-func-const-async.template +/*--- +description: Rest element (array binding pattern) may not be followed by any element (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +negative: + phase: early + type: SyntaxError +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[1, 2, 3]]; +})(); + +async function fn() { + for await (const [...[x], y] of asyncIter) { + + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-not-final-id.js b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-not-final-id.js new file mode 100644 index 0000000000..8f5dea0e33 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-not-final-id.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-id.case +// - src/dstr-binding/default/for-await-of-async-func-const-async.template +/*--- +description: Rest element (identifier) may not be followed by any element (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +negative: + phase: early + type: SyntaxError +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[1, 2, 3]]; +})(); + +async function fn() { + for await (const [...x, y] of asyncIter) { + + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-not-final-obj.js b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-not-final-obj.js new file mode 100644 index 0000000000..f68ecb5124 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-not-final-obj.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-obj.case +// - src/dstr-binding/default/for-await-of-async-func-const-async.template +/*--- +description: Rest element (object binding pattern) may not be followed by any element (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +negative: + phase: early + type: SyntaxError +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[1, 2, 3]]; +})(); + +async function fn() { + for await (const [...{ x }, y] of asyncIter) { + + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-obj-id.js b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-obj-id.js new file mode 100644 index 0000000000..e37b6f53be --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-obj-id.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-id.case +// - src/dstr-binding/default/for-await-of-async-func-const-async.template +/*--- +description: Rest element containing an object binding pattern (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[1, 2, 3]]; +})(); + +async function fn() { + for await (const [...{ length }] of asyncIter) { + assert.sameValue(length, 3); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-obj-prop-id.js b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-obj-prop-id.js new file mode 100644 index 0000000000..9fe2e241b3 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-obj-prop-id.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-prop-id.case +// - src/dstr-binding/default/for-await-of-async-func-const-async.template +/*--- +description: Rest element containing an object binding pattern (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +let length = "outer"; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[7, 8, 9]]; +})(); + +async function fn() { + for await (const [...{ 0: v, 1: w, 2: x, 3: y, length: z }] of asyncIter) { + assert.sameValue(v, 7); + assert.sameValue(w, 8); + assert.sameValue(x, 9); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + assert.sameValue(length, "outer", "the length prop is not set as a binding name"); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-empty.js b/test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-empty.js new file mode 100644 index 0000000000..ea327b594d --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-empty.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-empty.case +// - src/dstr-binding/default/for-await-of-async-func-const-async.template +/*--- +description: No property access occurs for an "empty" object binding pattern (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ +var accessCount = 0; +var obj = Object.defineProperty({}, 'attr', { + get: function() { + accessCount += 1; + } +}); + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [obj]; +})(); + +async function fn() { + for await (const {} of asyncIter) { + assert.sameValue(accessCount, 0); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-id-init-fn-name-arrow.js b/test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..9312b58ed3 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-id-init-fn-name-arrow.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-arrow.case +// - src/dstr-binding/default/for-await-of-async-func-const-async.template +/*--- +description: SingleNameBinding assigns `name` to arrow functions (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{}]; +})(); + +async function fn() { + for await (const { arrow = () => {} } of asyncIter) { + assert.sameValue(arrow.name, 'arrow'); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-id-init-fn-name-class.js b/test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-id-init-fn-name-class.js new file mode 100644 index 0000000000..57abee7c53 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-id-init-fn-name-class.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-class.case +// - src/dstr-binding/default/for-await-of-async-func-const-async.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{}]; +})(); + +async function fn() { + for await (const { cls = class {}, xCls = class X {}, xCls2 = class { static name() {} } } of asyncIter) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + assert.notSameValue(xCls2.name, 'xCls2'); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-id-init-fn-name-cover.js b/test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-id-init-fn-name-cover.js new file mode 100644 index 0000000000..07cd9b241f --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-id-init-fn-name-cover.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-cover.case +// - src/dstr-binding/default/for-await-of-async-func-const-async.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{}]; +})(); + +async function fn() { + for await (const { cover = (function () {}), xCover = (0, function() {}) } of asyncIter) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-id-init-fn-name-fn.js b/test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-id-init-fn-name-fn.js new file mode 100644 index 0000000000..1842788fdb --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-id-init-fn-name-fn.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-fn.case +// - src/dstr-binding/default/for-await-of-async-func-const-async.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{}]; +})(); + +async function fn() { + for await (const { fn = function () {}, xFn = function x() {} } of asyncIter) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-id-init-fn-name-gen.js b/test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-id-init-fn-name-gen.js new file mode 100644 index 0000000000..c5587df7ff --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-id-init-fn-name-gen.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-gen.case +// - src/dstr-binding/default/for-await-of-async-func-const-async.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{}]; +})(); + +async function fn() { + for await (const { gen = function* () {}, xGen = function* x() {} } of asyncIter) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-id-init-skipped.js b/test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-id-init-skipped.js new file mode 100644 index 0000000000..d72111b6ca --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-id-init-skipped.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-skipped.case +// - src/dstr-binding/default/for-await-of-async-func-const-async.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{ w: null, x: 0, y: false, z: '' }]; +})(); + +async function fn() { + for await (const { w = counter(), x = counter(), y = counter(), z = counter() } of asyncIter) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-id-trailing-comma.js b/test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-id-trailing-comma.js new file mode 100644 index 0000000000..032eaa430e --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-id-trailing-comma.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-trailing-comma.case +// - src/dstr-binding/default/for-await-of-async-func-const-async.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{ x: 23 }]; +})(); + +async function fn() { + for await (const { x, } of asyncIter) { + assert.sameValue(x, 23); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-prop-ary-init.js b/test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-prop-ary-init.js new file mode 100644 index 0000000000..b4b8f6f56e --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-prop-ary-init.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-init.case +// - src/dstr-binding/default/for-await-of-async-func-const-async.template +/*--- +description: Object binding pattern with "nested" array binding pattern using initializer (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{}]; +})(); + +async function fn() { + for await (const { w: [x, y, z] = [4, 5, 6] } of asyncIter) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-prop-ary-trailing-comma.js b/test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-prop-ary-trailing-comma.js new file mode 100644 index 0000000000..2901548ce4 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-prop-ary-trailing-comma.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-trailing-comma.case +// - src/dstr-binding/default/for-await-of-async-func-const-async.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{ x: [45] }]; +})(); + +async function fn() { + for await (const { x: [y], } of asyncIter) { + assert.sameValue(y,45); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-prop-ary.js b/test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-prop-ary.js new file mode 100644 index 0000000000..1fc91a8d7d --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-prop-ary.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary.case +// - src/dstr-binding/default/for-await-of-async-func-const-async.template +/*--- +description: Object binding pattern with "nested" array binding pattern not using initializer (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{ w: [7, undefined, ] }]; +})(); + +async function fn() { + for await (const { w: [x, y, z] = [4, 5, 6] } of asyncIter) { + assert.sameValue(x, 7); + assert.sameValue(y, undefined); + assert.sameValue(z, undefined); + + assert.throws(ReferenceError, function() { + w; + }); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-prop-id-init-skipped.js b/test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-prop-id-init-skipped.js new file mode 100644 index 0000000000..0d3c412c1b --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-prop-id-init-skipped.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case +// - src/dstr-binding/default/for-await-of-async-func-const-async.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{ s: null, u: 0, w: false, y: '' }]; +})(); + +async function fn() { + for await (const { s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() } of asyncIter) { + assert.sameValue(t, null); + assert.sameValue(v, 0); + assert.sameValue(x, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + assert.throws(ReferenceError, function() { + s; + }); + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-prop-id-init.js b/test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-prop-id-init.js new file mode 100644 index 0000000000..4b12eca9a3 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-prop-id-init.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init.case +// - src/dstr-binding/default/for-await-of-async-func-const-async.template +/*--- +description: Binding as specified via property name, identifier, and initializer (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{ }]; +})(); + +async function fn() { + for await (const { x: y = 33 } of asyncIter) { + assert.sameValue(y, 33); + assert.throws(ReferenceError, function() { + x; + }); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-prop-id-trailing-comma.js b/test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-prop-id-trailing-comma.js new file mode 100644 index 0000000000..314757b15e --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-prop-id-trailing-comma.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-trailing-comma.case +// - src/dstr-binding/default/for-await-of-async-func-const-async.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{ x: 23 }]; +})(); + +async function fn() { + for await (const { x: y, } of asyncIter) { + assert.sameValue(y, 23); + + assert.throws(ReferenceError, function() { + x; + }); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-prop-id.js b/test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-prop-id.js new file mode 100644 index 0000000000..33278b9480 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-prop-id.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id.case +// - src/dstr-binding/default/for-await-of-async-func-const-async.template +/*--- +description: Binding as specified via property name and identifier (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{ x: 23 }]; +})(); + +async function fn() { + for await (const { x: y } of asyncIter) { + assert.sameValue(y, 23); + assert.throws(ReferenceError, function() { + x; + }); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-prop-obj-init.js b/test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-prop-obj-init.js new file mode 100644 index 0000000000..3695afc8f3 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-prop-obj-init.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-init.case +// - src/dstr-binding/default/for-await-of-async-func-const-async.template +/*--- +description: Object binding pattern with "nested" object binding pattern using initializer (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{ w: undefined }]; +})(); + +async function fn() { + for await (const { w: { x, y, z } = { x: 4, y: 5, z: 6 } } of asyncIter) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-prop-obj.js b/test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-prop-obj.js new file mode 100644 index 0000000000..6a4b31edb8 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-prop-obj.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj.case +// - src/dstr-binding/default/for-await-of-async-func-const-async.template +/*--- +description: Object binding pattern with "nested" object binding pattern not using initializer (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{ w: { x: undefined, z: 7 } }]; +})(); + +async function fn() { + for await (const { w: { x, y, z } = { x: 4, y: 5, z: 6 } } of asyncIter) { + assert.sameValue(x, undefined); + assert.sameValue(y, undefined); + assert.sameValue(z, 7); + + assert.throws(ReferenceError, function() { + w; + }); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-rest-getter.js b/test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-rest-getter.js new file mode 100644 index 0000000000..522972b6e1 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-rest-getter.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-getter.case +// - src/dstr-binding/default/for-await-of-async-func-const-async.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [object-rest, destructuring-binding, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] +---*/ +var count = 0; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{ get v() { count++; return 2; } }]; +})(); + +async function fn() { + for await (const {...x} of asyncIter) { + assert.sameValue(x.v, 2); + assert.sameValue(count, 1); + + verifyEnumerable(x, "v"); + verifyWritable(x, "v"); + verifyConfigurable(x, "v"); + + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-rest-nested-obj.js b/test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-rest-nested-obj.js new file mode 100644 index 0000000000..b67f6bd417 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-rest-nested-obj.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-nested-obj.case +// - src/dstr-binding/default/for-await-of-async-func-const-async.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment. (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [object-rest, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] +---*/ +var obj = {a: 3, b: 4}; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{a: 1, b: 2, c: 3, d: 4, e: 5}]; +})(); + +async function fn() { + for await (const {a, b, ...{c, e}} of asyncIter) { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + assert.sameValue(e, 5); + + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-rest-obj-nested-rest.js b/test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-rest-obj-nested-rest.js new file mode 100644 index 0000000000..6e671982d6 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-rest-obj-nested-rest.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-nested-rest.case +// - src/dstr-binding/default/for-await-of-async-func-const-async.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment and object rest desconstruction is allowed in that case. (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [object-rest, destructuring-binding, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{a: 1, b: 2, c: 3, d: 4, e: 5}]; +})(); + +async function fn() { + for await (const {a, b, ...{c, ...rest}} of asyncIter) { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + + assert.sameValue(rest.d, 4); + assert.sameValue(rest.e, 5); + + verifyEnumerable(rest, "d"); + verifyWritable(rest, "d"); + verifyConfigurable(rest, "d"); + + verifyEnumerable(rest, "e"); + verifyWritable(rest, "e"); + verifyConfigurable(rest, "e"); + + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-rest-obj-own-property.js b/test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-rest-obj-own-property.js new file mode 100644 index 0000000000..224963260e --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-rest-obj-own-property.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-own-property.case +// - src/dstr-binding/default/for-await-of-async-func-const-async.template +/*--- +description: Rest object contains just soruce object's own properties (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [object-rest, destructuring-binding, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] +---*/ +var o = Object.create({ x: 1, y: 2 }); +o.z = 3; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [o]; +})(); + +async function fn() { + for await (const { x, ...{y , z} } of asyncIter) { + assert.sameValue(x, 1); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-rest-skip-non-enumerable.js b/test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..218409b566 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-rest-skip-non-enumerable.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-skip-non-enumerable.case +// - src/dstr-binding/default/for-await-of-async-func-const-async.template +/*--- +description: Rest object doesn't contain non-enumerable properties (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [object-rest, destructuring-binding, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] +---*/ +var o = {a: 3, b: 4}; +Object.defineProperty(o, "x", { value: 4, enumerable: false }); + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [o]; +})(); + +async function fn() { + for await (const {...rest} of asyncIter) { + assert.sameValue(rest.a, 3); + assert.sameValue(rest.b, 4); + assert.sameValue(rest.x, undefined); + + verifyEnumerable(rest, "a"); + verifyWritable(rest, "a"); + verifyConfigurable(rest, "a"); + + verifyEnumerable(rest, "b"); + verifyWritable(rest, "b"); + verifyConfigurable(rest, "b"); + + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-rest-val-obj.js b/test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-rest-val-obj.js new file mode 100644 index 0000000000..25bfc0ae85 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-rest-val-obj.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-val-obj.case +// - src/dstr-binding/default/for-await-of-async-func-const-async.template +/*--- +description: Rest object contains just unextracted data (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [object-rest, destructuring-binding, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{x: 1, y: 2, a: 5, b: 3}]; +})(); + +async function fn() { + for await (const {a, b, ...rest} of asyncIter) { + assert.sameValue(rest.x, 1); + assert.sameValue(rest.y, 2); + assert.sameValue(rest.a, undefined); + assert.sameValue(rest.b, undefined); + + verifyEnumerable(rest, "x"); + verifyWritable(rest, "x"); + verifyConfigurable(rest, "x"); + + verifyEnumerable(rest, "y"); + verifyWritable(rest, "y"); + verifyConfigurable(rest, "y"); + + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-let-async-ary-init-iter-close.js b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-init-iter-close.js new file mode 100644 index 0000000000..89ca96204d --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-init-iter-close.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-close.case +// - src/dstr-binding/default/for-await-of-async-func-let-async.template +/*--- +description: Iterator is closed when not exhausted by pattern evaluation (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [Symbol.iterator, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: false }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [iter]; +})(); + +async function fn() { + for await (let [x] of asyncIter) { + assert.sameValue(doneCallCount, 1); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-let-async-ary-init-iter-no-close.js b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-init-iter-no-close.js new file mode 100644 index 0000000000..6f4c9e35dd --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-init-iter-no-close.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-no-close.case +// - src/dstr-binding/default/for-await-of-async-func-let-async.template +/*--- +description: Iterator is not closed when exhausted by pattern evaluation (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [Symbol.iterator, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: true }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [iter]; +})(); + +async function fn() { + for await (let [x] of asyncIter) { + assert.sameValue(doneCallCount, 0); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-let-async-ary-name-iter-val.js b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-name-iter-val.js new file mode 100644 index 0000000000..150b2b6fa5 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-name-iter-val.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-name-iter-val.case +// - src/dstr-binding/default/for-await-of-async-func-let-async.template +/*--- +description: SingleNameBinding with normal value iteration (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[1, 2, 3]]; +})(); + +async function fn() { + for await (let [x, y, z] of asyncIter) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-ary-elem-init.js b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-ary-elem-init.js new file mode 100644 index 0000000000..0c373c5f60 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-ary-elem-init.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-init.case +// - src/dstr-binding/default/for-await-of-async-func-let-async.template +/*--- +description: BindingElement with array binding pattern and initializer is used (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function fn() { + for await (let [[x, y, z] = [4, 5, 6]] of asyncIter) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-ary-elem-iter.js b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-ary-elem-iter.js new file mode 100644 index 0000000000..67a3720ac1 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-ary-elem-iter.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-iter.case +// - src/dstr-binding/default/for-await-of-async-func-let-async.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[[7, 8, 9]]]; +})(); + +async function fn() { + for await (let [[x, y, z] = [4, 5, 6]] of asyncIter) { + assert.sameValue(x, 7); + assert.sameValue(y, 8); + assert.sameValue(z, 9); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-ary-elision-init.js b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-ary-elision-init.js new file mode 100644 index 0000000000..e350d5e42f --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-ary-elision-init.js @@ -0,0 +1,75 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case +// - src/dstr-binding/default/for-await-of-async-func-let-async.template +/*--- +description: BindingElement with array binding pattern and initializer is used (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [generators, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function fn() { + for await (let [[,] = g()] of asyncIter) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-ary-elision-iter.js b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-ary-elision-iter.js new file mode 100644 index 0000000000..f76dcc5f9f --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-ary-elision-iter.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-iter.case +// - src/dstr-binding/default/for-await-of-async-func-let-async.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [generators, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var callCount = 0; +function* g() { + callCount += 1; +}; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[[]]]; +})(); + +async function fn() { + for await (let [[,] = g()] of asyncIter) { + assert.sameValue(callCount, 0); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-ary-empty-init.js b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-ary-empty-init.js new file mode 100644 index 0000000000..235714cf65 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-ary-empty-init.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-init.case +// - src/dstr-binding/default/for-await-of-async-func-let-async.template +/*--- +description: BindingElement with array binding pattern and initializer is used (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; +var iterCount = 0; +var iter = function*() { iterCount += 1; }(); + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function fn() { + for await (let [[] = function() { initCount += 1; return iter; }()] of asyncIter) { + assert.sameValue(initCount, 1); + assert.sameValue(iterCount, 0); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-ary-empty-iter.js b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-ary-empty-iter.js new file mode 100644 index 0000000000..35bcf39b05 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-ary-empty-iter.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-iter.case +// - src/dstr-binding/default/for-await-of-async-func-let-async.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[[23]]]; +})(); + +async function fn() { + for await (let [[] = function() { initCount += 1; }()] of asyncIter) { + assert.sameValue(initCount, 0); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-ary-rest-init.js b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-ary-rest-init.js new file mode 100644 index 0000000000..ea51a1d30d --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-ary-rest-init.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-init.case +// - src/dstr-binding/default/for-await-of-async-func-let-async.template +/*--- +description: BindingElement with array binding pattern and initializer is used (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function fn() { + for await (let [[...x] = values] of asyncIter) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-ary-rest-iter.js b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-ary-rest-iter.js new file mode 100644 index 0000000000..87d89dec16 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-ary-rest-iter.js @@ -0,0 +1,75 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-iter.case +// - src/dstr-binding/default/for-await-of-async-func-let-async.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; +var initCount = 0; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[values]]; +})(); + +async function fn() { + for await (let [[...x] = function() { initCount += 1; }()] of asyncIter) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + assert.sameValue(initCount, 0); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-init-exhausted.js b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-init-exhausted.js new file mode 100644 index 0000000000..cc6bfb62fd --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-init-exhausted.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-exhausted.case +// - src/dstr-binding/default/for-await-of-async-func-let-async.template +/*--- +description: Destructuring initializer with an exhausted iterator (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function fn() { + for await (let [x = 23] of asyncIter) { + assert.sameValue(x, 23); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-init-fn-name-arrow.js b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..fddee0a259 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-init-fn-name-arrow.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-arrow.case +// - src/dstr-binding/default/for-await-of-async-func-let-async.template +/*--- +description: SingleNameBinding does assign name to arrow functions (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function fn() { + for await (let [arrow = () => {}] of asyncIter) { + assert.sameValue(arrow.name, 'arrow'); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-init-fn-name-class.js b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-init-fn-name-class.js new file mode 100644 index 0000000000..40e89f2876 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-init-fn-name-class.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-class.case +// - src/dstr-binding/default/for-await-of-async-func-let-async.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function fn() { + for await (let [cls = class {}, xCls = class X {}, xCls2 = class { static name() {} }] of asyncIter) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + assert.notSameValue(xCls2.name, 'xCls2'); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-init-fn-name-cover.js b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-init-fn-name-cover.js new file mode 100644 index 0000000000..779318b324 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-init-fn-name-cover.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-cover.case +// - src/dstr-binding/default/for-await-of-async-func-let-async.template +/*--- +description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function fn() { + for await (let [cover = (function () {}), xCover = (0, function() {})] of asyncIter) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-init-fn-name-fn.js b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-init-fn-name-fn.js new file mode 100644 index 0000000000..b66557b77c --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-init-fn-name-fn.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-fn.case +// - src/dstr-binding/default/for-await-of-async-func-let-async.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function fn() { + for await (let [fn = function () {}, xFn = function x() {}] of asyncIter) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-init-fn-name-gen.js b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-init-fn-name-gen.js new file mode 100644 index 0000000000..f9753954e8 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-init-fn-name-gen.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-gen.case +// - src/dstr-binding/default/for-await-of-async-func-let-async.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function fn() { + for await (let [gen = function* () {}, xGen = function* x() {}] of asyncIter) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-init-hole.js b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-init-hole.js new file mode 100644 index 0000000000..cc468edee0 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-init-hole.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-hole.case +// - src/dstr-binding/default/for-await-of-async-func-let-async.template +/*--- +description: Destructuring initializer with a "hole" (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + SingleNameBinding : BindingIdentifier Initializeropt + [...] 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[,]]; +})(); + +async function fn() { + for await (let [x = 23] of asyncIter) { + assert.sameValue(x, 23); + // another statement + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-init-skipped.js b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-init-skipped.js new file mode 100644 index 0000000000..40f5a7096a --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-init-skipped.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-skipped.case +// - src/dstr-binding/default/for-await-of-async-func-let-async.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[null, 0, false, '']]; +})(); + +async function fn() { + for await (let [w = counter(), x = counter(), y = counter(), z = counter()] of asyncIter) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-init-undef.js b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-init-undef.js new file mode 100644 index 0000000000..aeb52b58a0 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-init-undef.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-undef.case +// - src/dstr-binding/default/for-await-of-async-func-let-async.template +/*--- +description: Destructuring initializer with an undefined value (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[undefined]]; +})(); + +async function fn() { + for await (let [x = 23] of asyncIter) { + assert.sameValue(x, 23); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-iter-complete.js b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-iter-complete.js new file mode 100644 index 0000000000..cab1bbf67f --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-iter-complete.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-complete.case +// - src/dstr-binding/default/for-await-of-async-func-let-async.template +/*--- +description: SingleNameBinding when value iteration completes (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function fn() { + for await (let [x] of asyncIter) { + assert.sameValue(x, undefined); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-iter-done.js b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-iter-done.js new file mode 100644 index 0000000000..12e0d09c62 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-iter-done.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-done.case +// - src/dstr-binding/default/for-await-of-async-func-let-async.template +/*--- +description: SingleNameBinding when value iteration was completed previously (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function fn() { + for await (let [_, x] of asyncIter) { + assert.sameValue(x, undefined); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-iter-val.js b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-iter-val.js new file mode 100644 index 0000000000..f035c1d090 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-iter-val.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val.case +// - src/dstr-binding/default/for-await-of-async-func-let-async.template +/*--- +description: SingleNameBinding when value iteration was completed previously (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[1, 2, 3]]; +})(); + +async function fn() { + for await (let [x, y, z] of asyncIter) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-obj-id-init.js b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-obj-id-init.js new file mode 100644 index 0000000000..9bb94ca087 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-obj-id-init.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id-init.case +// - src/dstr-binding/default/for-await-of-async-func-let-async.template +/*--- +description: BindingElement with object binding pattern and initializer is used (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function fn() { + for await (let [{ x, y, z } = { x: 44, y: 55, z: 66 }] of asyncIter) { + assert.sameValue(x, 44); + assert.sameValue(y, 55); + assert.sameValue(z, 66); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-obj-id.js b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-obj-id.js new file mode 100644 index 0000000000..da37fef834 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-obj-id.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id.case +// - src/dstr-binding/default/for-await-of-async-func-let-async.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[{ x: 11, y: 22, z: 33 }]]; +})(); + +async function fn() { + for await (let [{ x, y, z } = { x: 44, y: 55, z: 66 }] of asyncIter) { + assert.sameValue(x, 11); + assert.sameValue(y, 22); + assert.sameValue(z, 33); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-obj-prop-id-init.js b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-obj-prop-id-init.js new file mode 100644 index 0000000000..0fadab5912 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-obj-prop-id-init.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id-init.case +// - src/dstr-binding/default/for-await-of-async-func-let-async.template +/*--- +description: BindingElement with object binding pattern and initializer is used (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function fn() { + for await (let [{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] of asyncIter) { + assert.sameValue(v, 444); + assert.sameValue(x, 555); + assert.sameValue(z, 666); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-obj-prop-id.js b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-obj-prop-id.js new file mode 100644 index 0000000000..00ab0f076b --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-obj-prop-id.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id.case +// - src/dstr-binding/default/for-await-of-async-func-let-async.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[{ u: 777, w: 888, y: 999 }]]; +})(); + +async function fn() { + for await (let [{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] of asyncIter) { + assert.sameValue(v, 777); + assert.sameValue(x, 888); + assert.sameValue(z, 999); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elision-exhausted.js b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elision-exhausted.js new file mode 100644 index 0000000000..b3ed5edbd4 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elision-exhausted.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-exhausted.case +// - src/dstr-binding/default/for-await-of-async-func-let-async.template +/*--- +description: Elision accepts exhausted iterator (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [generator, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + [...] + 2. Return NormalCompletion(empty). + +---*/ +var iter = function*() {}(); +iter.next(); + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [iter]; +})(); + +async function fn() { + for await (let [,] of asyncIter) { + + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elision.js b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elision.js new file mode 100644 index 0000000000..c78aa50717 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elision.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision.case +// - src/dstr-binding/default/for-await-of-async-func-let-async.template +/*--- +description: Elision advances iterator (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [generator, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [g()]; +})(); + +async function fn() { + for await (let [,] of asyncIter) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-empty.js b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-empty.js new file mode 100644 index 0000000000..b6cc6912e8 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-empty.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-empty.case +// - src/dstr-binding/default/for-await-of-async-func-let-async.template +/*--- +description: No iteration occurs for an "empty" array binding pattern (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [generators, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [iter]; +})(); + +async function fn() { + for await (let [] of asyncIter) { + assert.sameValue(iterations, 0); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-ary-elem.js b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-ary-elem.js new file mode 100644 index 0000000000..5a4c816619 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-ary-elem.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elem.case +// - src/dstr-binding/default/for-await-of-async-func-let-async.template +/*--- +description: Rest element containing an array BindingElementList pattern (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[3, 4, 5]]; +})(); + +async function fn() { + for await (let [...[x, y, z]] of asyncIter) { + assert.sameValue(x, 3); + assert.sameValue(y, 4); + assert.sameValue(z, 5); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-ary-elision.js b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-ary-elision.js new file mode 100644 index 0000000000..29fb962c88 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-ary-elision.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elision.case +// - src/dstr-binding/default/for-await-of-async-func-let-async.template +/*--- +description: Rest element containing an elision (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [generators, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [g()]; +})(); + +async function fn() { + for await (let [...[,]] of asyncIter) { + assert.sameValue(first, 1); + assert.sameValue(second, 1); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-ary-empty.js b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-ary-empty.js new file mode 100644 index 0000000000..dbcc88af2c --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-ary-empty.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-empty.case +// - src/dstr-binding/default/for-await-of-async-func-let-async.template +/*--- +description: Rest element containing an "empty" array pattern (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [generators, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [iter]; +})(); + +async function fn() { + for await (let [...[]] of asyncIter) { + assert.sameValue(iterations, 1); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-ary-rest.js b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-ary-rest.js new file mode 100644 index 0000000000..0faa4dbf16 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-ary-rest.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-rest.case +// - src/dstr-binding/default/for-await-of-async-func-let-async.template +/*--- +description: Rest element containing a rest element (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +var values = [1, 2, 3]; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [values]; +})(); + +async function fn() { + for await (let [...[...x]] of asyncIter) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-id-elision.js b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-id-elision.js new file mode 100644 index 0000000000..e111cb1811 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-id-elision.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision.case +// - src/dstr-binding/default/for-await-of-async-func-let-async.template +/*--- +description: Rest element following elision elements (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. +---*/ +var values = [1, 2, 3, 4, 5]; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [values]; +})(); + +async function fn() { + for await (let [ , , ...x] of asyncIter) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 3); + assert.sameValue(x[1], 4); + assert.sameValue(x[2], 5); + assert.notSameValue(x, values); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-id-exhausted.js b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-id-exhausted.js new file mode 100644 index 0000000000..fddf10d574 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-id-exhausted.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-exhausted.case +// - src/dstr-binding/default/for-await-of-async-func-let-async.template +/*--- +description: RestElement applied to an exhausted iterator (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [Symbol.iterator, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + b. If iteratorRecord.[[done]] is true, then + i. If environment is undefined, return PutValue(lhs, A). + ii. Return InitializeReferencedBinding(lhs, A). + +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[1, 2]]; +})(); + +async function fn() { + for await (let [, , ...x] of asyncIter) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 0); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-id.js b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-id.js new file mode 100644 index 0000000000..5eaa9e14d3 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-id.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id.case +// - src/dstr-binding/default/for-await-of-async-func-let-async.template +/*--- +description: Lone rest element (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat + [...] + f. Let status be CreateDataProperty(A, ToString (n), nextValue). + [...] +---*/ +var values = [1, 2, 3]; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [values]; +})(); + +async function fn() { + for await (let [...x] of asyncIter) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-init-ary.js b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-init-ary.js new file mode 100644 index 0000000000..88a93910ef --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-init-ary.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-ary.case +// - src/dstr-binding/default/for-await-of-async-func-let-async.template +/*--- +description: Reset element (nested array pattern) does not support initializer (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +negative: + phase: early + type: SyntaxError +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function fn() { + for await (let [...[ x ] = []] of asyncIter) { + + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-init-id.js b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-init-id.js new file mode 100644 index 0000000000..b9b64dd4ca --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-init-id.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-id.case +// - src/dstr-binding/default/for-await-of-async-func-let-async.template +/*--- +description: Reset element (identifier) does not support initializer (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +negative: + phase: early + type: SyntaxError +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function fn() { + for await (let [...x = []] of asyncIter) { + + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-init-obj.js b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-init-obj.js new file mode 100644 index 0000000000..9c40a15f9f --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-init-obj.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-obj.case +// - src/dstr-binding/default/for-await-of-async-func-let-async.template +/*--- +description: Reset element (nested object pattern) does not support initializer (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +negative: + phase: early + type: SyntaxError +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function fn() { + for await (let [...{ x } = []] of asyncIter) { + + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-not-final-ary.js b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-not-final-ary.js new file mode 100644 index 0000000000..f13533ca8d --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-not-final-ary.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-ary.case +// - src/dstr-binding/default/for-await-of-async-func-let-async.template +/*--- +description: Rest element (array binding pattern) may not be followed by any element (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +negative: + phase: early + type: SyntaxError +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[1, 2, 3]]; +})(); + +async function fn() { + for await (let [...[x], y] of asyncIter) { + + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-not-final-id.js b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-not-final-id.js new file mode 100644 index 0000000000..4c09dd7f46 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-not-final-id.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-id.case +// - src/dstr-binding/default/for-await-of-async-func-let-async.template +/*--- +description: Rest element (identifier) may not be followed by any element (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +negative: + phase: early + type: SyntaxError +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[1, 2, 3]]; +})(); + +async function fn() { + for await (let [...x, y] of asyncIter) { + + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-not-final-obj.js b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-not-final-obj.js new file mode 100644 index 0000000000..6255f00fdb --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-not-final-obj.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-obj.case +// - src/dstr-binding/default/for-await-of-async-func-let-async.template +/*--- +description: Rest element (object binding pattern) may not be followed by any element (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +negative: + phase: early + type: SyntaxError +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[1, 2, 3]]; +})(); + +async function fn() { + for await (let [...{ x }, y] of asyncIter) { + + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-obj-id.js b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-obj-id.js new file mode 100644 index 0000000000..cfb6caef8c --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-obj-id.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-id.case +// - src/dstr-binding/default/for-await-of-async-func-let-async.template +/*--- +description: Rest element containing an object binding pattern (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[1, 2, 3]]; +})(); + +async function fn() { + for await (let [...{ length }] of asyncIter) { + assert.sameValue(length, 3); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-obj-prop-id.js b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-obj-prop-id.js new file mode 100644 index 0000000000..a3686b5658 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-obj-prop-id.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-prop-id.case +// - src/dstr-binding/default/for-await-of-async-func-let-async.template +/*--- +description: Rest element containing an object binding pattern (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +let length = "outer"; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[7, 8, 9]]; +})(); + +async function fn() { + for await (let [...{ 0: v, 1: w, 2: x, 3: y, length: z }] of asyncIter) { + assert.sameValue(v, 7); + assert.sameValue(w, 8); + assert.sameValue(x, 9); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + assert.sameValue(length, "outer", "the length prop is not set as a binding name"); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-empty.js b/test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-empty.js new file mode 100644 index 0000000000..442b59f9ce --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-empty.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-empty.case +// - src/dstr-binding/default/for-await-of-async-func-let-async.template +/*--- +description: No property access occurs for an "empty" object binding pattern (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ +var accessCount = 0; +var obj = Object.defineProperty({}, 'attr', { + get: function() { + accessCount += 1; + } +}); + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [obj]; +})(); + +async function fn() { + for await (let {} of asyncIter) { + assert.sameValue(accessCount, 0); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-id-init-fn-name-arrow.js b/test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..1deabbc454 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-id-init-fn-name-arrow.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-arrow.case +// - src/dstr-binding/default/for-await-of-async-func-let-async.template +/*--- +description: SingleNameBinding assigns `name` to arrow functions (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{}]; +})(); + +async function fn() { + for await (let { arrow = () => {} } of asyncIter) { + assert.sameValue(arrow.name, 'arrow'); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-id-init-fn-name-class.js b/test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-id-init-fn-name-class.js new file mode 100644 index 0000000000..0af1abc181 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-id-init-fn-name-class.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-class.case +// - src/dstr-binding/default/for-await-of-async-func-let-async.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{}]; +})(); + +async function fn() { + for await (let { cls = class {}, xCls = class X {}, xCls2 = class { static name() {} } } of asyncIter) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + assert.notSameValue(xCls2.name, 'xCls2'); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-id-init-fn-name-cover.js b/test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-id-init-fn-name-cover.js new file mode 100644 index 0000000000..3a0a9a4f85 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-id-init-fn-name-cover.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-cover.case +// - src/dstr-binding/default/for-await-of-async-func-let-async.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{}]; +})(); + +async function fn() { + for await (let { cover = (function () {}), xCover = (0, function() {}) } of asyncIter) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-id-init-fn-name-fn.js b/test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-id-init-fn-name-fn.js new file mode 100644 index 0000000000..80f255e45a --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-id-init-fn-name-fn.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-fn.case +// - src/dstr-binding/default/for-await-of-async-func-let-async.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{}]; +})(); + +async function fn() { + for await (let { fn = function () {}, xFn = function x() {} } of asyncIter) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-id-init-fn-name-gen.js b/test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-id-init-fn-name-gen.js new file mode 100644 index 0000000000..4d122d3e98 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-id-init-fn-name-gen.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-gen.case +// - src/dstr-binding/default/for-await-of-async-func-let-async.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{}]; +})(); + +async function fn() { + for await (let { gen = function* () {}, xGen = function* x() {} } of asyncIter) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-id-init-skipped.js b/test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-id-init-skipped.js new file mode 100644 index 0000000000..31ca7171af --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-id-init-skipped.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-skipped.case +// - src/dstr-binding/default/for-await-of-async-func-let-async.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{ w: null, x: 0, y: false, z: '' }]; +})(); + +async function fn() { + for await (let { w = counter(), x = counter(), y = counter(), z = counter() } of asyncIter) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-id-trailing-comma.js b/test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-id-trailing-comma.js new file mode 100644 index 0000000000..9f32a86d26 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-id-trailing-comma.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-trailing-comma.case +// - src/dstr-binding/default/for-await-of-async-func-let-async.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{ x: 23 }]; +})(); + +async function fn() { + for await (let { x, } of asyncIter) { + assert.sameValue(x, 23); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-prop-ary-init.js b/test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-prop-ary-init.js new file mode 100644 index 0000000000..8983357d36 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-prop-ary-init.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-init.case +// - src/dstr-binding/default/for-await-of-async-func-let-async.template +/*--- +description: Object binding pattern with "nested" array binding pattern using initializer (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{}]; +})(); + +async function fn() { + for await (let { w: [x, y, z] = [4, 5, 6] } of asyncIter) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-prop-ary-trailing-comma.js b/test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-prop-ary-trailing-comma.js new file mode 100644 index 0000000000..f4c09486c3 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-prop-ary-trailing-comma.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-trailing-comma.case +// - src/dstr-binding/default/for-await-of-async-func-let-async.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{ x: [45] }]; +})(); + +async function fn() { + for await (let { x: [y], } of asyncIter) { + assert.sameValue(y,45); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-prop-ary.js b/test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-prop-ary.js new file mode 100644 index 0000000000..6ee201d9e4 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-prop-ary.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary.case +// - src/dstr-binding/default/for-await-of-async-func-let-async.template +/*--- +description: Object binding pattern with "nested" array binding pattern not using initializer (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{ w: [7, undefined, ] }]; +})(); + +async function fn() { + for await (let { w: [x, y, z] = [4, 5, 6] } of asyncIter) { + assert.sameValue(x, 7); + assert.sameValue(y, undefined); + assert.sameValue(z, undefined); + + assert.throws(ReferenceError, function() { + w; + }); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-prop-id-init-skipped.js b/test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-prop-id-init-skipped.js new file mode 100644 index 0000000000..be2c745522 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-prop-id-init-skipped.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case +// - src/dstr-binding/default/for-await-of-async-func-let-async.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{ s: null, u: 0, w: false, y: '' }]; +})(); + +async function fn() { + for await (let { s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() } of asyncIter) { + assert.sameValue(t, null); + assert.sameValue(v, 0); + assert.sameValue(x, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + assert.throws(ReferenceError, function() { + s; + }); + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-prop-id-init.js b/test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-prop-id-init.js new file mode 100644 index 0000000000..83c5f68f56 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-prop-id-init.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init.case +// - src/dstr-binding/default/for-await-of-async-func-let-async.template +/*--- +description: Binding as specified via property name, identifier, and initializer (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{ }]; +})(); + +async function fn() { + for await (let { x: y = 33 } of asyncIter) { + assert.sameValue(y, 33); + assert.throws(ReferenceError, function() { + x; + }); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-prop-id-trailing-comma.js b/test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-prop-id-trailing-comma.js new file mode 100644 index 0000000000..6bc04fa8ff --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-prop-id-trailing-comma.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-trailing-comma.case +// - src/dstr-binding/default/for-await-of-async-func-let-async.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{ x: 23 }]; +})(); + +async function fn() { + for await (let { x: y, } of asyncIter) { + assert.sameValue(y, 23); + + assert.throws(ReferenceError, function() { + x; + }); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-prop-id.js b/test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-prop-id.js new file mode 100644 index 0000000000..801755c156 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-prop-id.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id.case +// - src/dstr-binding/default/for-await-of-async-func-let-async.template +/*--- +description: Binding as specified via property name and identifier (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{ x: 23 }]; +})(); + +async function fn() { + for await (let { x: y } of asyncIter) { + assert.sameValue(y, 23); + assert.throws(ReferenceError, function() { + x; + }); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-prop-obj-init.js b/test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-prop-obj-init.js new file mode 100644 index 0000000000..37f0e1107a --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-prop-obj-init.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-init.case +// - src/dstr-binding/default/for-await-of-async-func-let-async.template +/*--- +description: Object binding pattern with "nested" object binding pattern using initializer (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{ w: undefined }]; +})(); + +async function fn() { + for await (let { w: { x, y, z } = { x: 4, y: 5, z: 6 } } of asyncIter) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-prop-obj.js b/test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-prop-obj.js new file mode 100644 index 0000000000..60f704eefd --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-prop-obj.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj.case +// - src/dstr-binding/default/for-await-of-async-func-let-async.template +/*--- +description: Object binding pattern with "nested" object binding pattern not using initializer (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{ w: { x: undefined, z: 7 } }]; +})(); + +async function fn() { + for await (let { w: { x, y, z } = { x: 4, y: 5, z: 6 } } of asyncIter) { + assert.sameValue(x, undefined); + assert.sameValue(y, undefined); + assert.sameValue(z, 7); + + assert.throws(ReferenceError, function() { + w; + }); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-rest-getter.js b/test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-rest-getter.js new file mode 100644 index 0000000000..857d7101c2 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-rest-getter.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-getter.case +// - src/dstr-binding/default/for-await-of-async-func-let-async.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [object-rest, destructuring-binding, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] +---*/ +var count = 0; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{ get v() { count++; return 2; } }]; +})(); + +async function fn() { + for await (let {...x} of asyncIter) { + assert.sameValue(x.v, 2); + assert.sameValue(count, 1); + + verifyEnumerable(x, "v"); + verifyWritable(x, "v"); + verifyConfigurable(x, "v"); + + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-rest-nested-obj.js b/test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-rest-nested-obj.js new file mode 100644 index 0000000000..e43f13c8a8 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-rest-nested-obj.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-nested-obj.case +// - src/dstr-binding/default/for-await-of-async-func-let-async.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment. (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [object-rest, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] +---*/ +var obj = {a: 3, b: 4}; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{a: 1, b: 2, c: 3, d: 4, e: 5}]; +})(); + +async function fn() { + for await (let {a, b, ...{c, e}} of asyncIter) { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + assert.sameValue(e, 5); + + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-rest-obj-nested-rest.js b/test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-rest-obj-nested-rest.js new file mode 100644 index 0000000000..cc2cfc885a --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-rest-obj-nested-rest.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-nested-rest.case +// - src/dstr-binding/default/for-await-of-async-func-let-async.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment and object rest desconstruction is allowed in that case. (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [object-rest, destructuring-binding, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{a: 1, b: 2, c: 3, d: 4, e: 5}]; +})(); + +async function fn() { + for await (let {a, b, ...{c, ...rest}} of asyncIter) { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + + assert.sameValue(rest.d, 4); + assert.sameValue(rest.e, 5); + + verifyEnumerable(rest, "d"); + verifyWritable(rest, "d"); + verifyConfigurable(rest, "d"); + + verifyEnumerable(rest, "e"); + verifyWritable(rest, "e"); + verifyConfigurable(rest, "e"); + + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-rest-obj-own-property.js b/test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-rest-obj-own-property.js new file mode 100644 index 0000000000..ff715eb126 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-rest-obj-own-property.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-own-property.case +// - src/dstr-binding/default/for-await-of-async-func-let-async.template +/*--- +description: Rest object contains just soruce object's own properties (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [object-rest, destructuring-binding, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] +---*/ +var o = Object.create({ x: 1, y: 2 }); +o.z = 3; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [o]; +})(); + +async function fn() { + for await (let { x, ...{y , z} } of asyncIter) { + assert.sameValue(x, 1); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-rest-skip-non-enumerable.js b/test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..2fc39d1c09 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-rest-skip-non-enumerable.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-skip-non-enumerable.case +// - src/dstr-binding/default/for-await-of-async-func-let-async.template +/*--- +description: Rest object doesn't contain non-enumerable properties (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [object-rest, destructuring-binding, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] +---*/ +var o = {a: 3, b: 4}; +Object.defineProperty(o, "x", { value: 4, enumerable: false }); + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [o]; +})(); + +async function fn() { + for await (let {...rest} of asyncIter) { + assert.sameValue(rest.a, 3); + assert.sameValue(rest.b, 4); + assert.sameValue(rest.x, undefined); + + verifyEnumerable(rest, "a"); + verifyWritable(rest, "a"); + verifyConfigurable(rest, "a"); + + verifyEnumerable(rest, "b"); + verifyWritable(rest, "b"); + verifyConfigurable(rest, "b"); + + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-rest-val-obj.js b/test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-rest-val-obj.js new file mode 100644 index 0000000000..c1a732dc2c --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-rest-val-obj.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-val-obj.case +// - src/dstr-binding/default/for-await-of-async-func-let-async.template +/*--- +description: Rest object contains just unextracted data (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [object-rest, destructuring-binding, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{x: 1, y: 2, a: 5, b: 3}]; +})(); + +async function fn() { + for await (let {a, b, ...rest} of asyncIter) { + assert.sameValue(rest.x, 1); + assert.sameValue(rest.y, 2); + assert.sameValue(rest.a, undefined); + assert.sameValue(rest.b, undefined); + + verifyEnumerable(rest, "x"); + verifyWritable(rest, "x"); + verifyConfigurable(rest, "x"); + + verifyEnumerable(rest, "y"); + verifyWritable(rest, "y"); + verifyConfigurable(rest, "y"); + + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-async-ary-init-iter-close.js b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-init-iter-close.js new file mode 100644 index 0000000000..3d64352fa2 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-init-iter-close.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-close.case +// - src/dstr-binding/default/for-await-of-async-func-var-async.template +/*--- +description: Iterator is closed when not exhausted by pattern evaluation (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [Symbol.iterator, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: false }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [iter]; +})(); + +async function fn() { + for await (var [x] of asyncIter) { + assert.sameValue(doneCallCount, 1); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-async-ary-init-iter-no-close.js b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-init-iter-no-close.js new file mode 100644 index 0000000000..2a8b27f6d0 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-init-iter-no-close.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-no-close.case +// - src/dstr-binding/default/for-await-of-async-func-var-async.template +/*--- +description: Iterator is not closed when exhausted by pattern evaluation (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [Symbol.iterator, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: true }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [iter]; +})(); + +async function fn() { + for await (var [x] of asyncIter) { + assert.sameValue(doneCallCount, 0); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-async-ary-name-iter-val.js b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-name-iter-val.js new file mode 100644 index 0000000000..ffb4c03723 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-name-iter-val.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-name-iter-val.case +// - src/dstr-binding/default/for-await-of-async-func-var-async.template +/*--- +description: SingleNameBinding with normal value iteration (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[1, 2, 3]]; +})(); + +async function fn() { + for await (var [x, y, z] of asyncIter) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-ary-elem-init.js b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-ary-elem-init.js new file mode 100644 index 0000000000..b6f692f23b --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-ary-elem-init.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-init.case +// - src/dstr-binding/default/for-await-of-async-func-var-async.template +/*--- +description: BindingElement with array binding pattern and initializer is used (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function fn() { + for await (var [[x, y, z] = [4, 5, 6]] of asyncIter) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-ary-elem-iter.js b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-ary-elem-iter.js new file mode 100644 index 0000000000..3118d453f3 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-ary-elem-iter.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-iter.case +// - src/dstr-binding/default/for-await-of-async-func-var-async.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[[7, 8, 9]]]; +})(); + +async function fn() { + for await (var [[x, y, z] = [4, 5, 6]] of asyncIter) { + assert.sameValue(x, 7); + assert.sameValue(y, 8); + assert.sameValue(z, 9); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-ary-elision-init.js b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-ary-elision-init.js new file mode 100644 index 0000000000..935fbe20b8 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-ary-elision-init.js @@ -0,0 +1,75 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case +// - src/dstr-binding/default/for-await-of-async-func-var-async.template +/*--- +description: BindingElement with array binding pattern and initializer is used (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [generators, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function fn() { + for await (var [[,] = g()] of asyncIter) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-ary-elision-iter.js b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-ary-elision-iter.js new file mode 100644 index 0000000000..279603fa7f --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-ary-elision-iter.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-iter.case +// - src/dstr-binding/default/for-await-of-async-func-var-async.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [generators, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var callCount = 0; +function* g() { + callCount += 1; +}; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[[]]]; +})(); + +async function fn() { + for await (var [[,] = g()] of asyncIter) { + assert.sameValue(callCount, 0); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-ary-empty-init.js b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-ary-empty-init.js new file mode 100644 index 0000000000..32f0130df2 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-ary-empty-init.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-init.case +// - src/dstr-binding/default/for-await-of-async-func-var-async.template +/*--- +description: BindingElement with array binding pattern and initializer is used (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; +var iterCount = 0; +var iter = function*() { iterCount += 1; }(); + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function fn() { + for await (var [[] = function() { initCount += 1; return iter; }()] of asyncIter) { + assert.sameValue(initCount, 1); + assert.sameValue(iterCount, 0); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-ary-empty-iter.js b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-ary-empty-iter.js new file mode 100644 index 0000000000..5893efc900 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-ary-empty-iter.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-iter.case +// - src/dstr-binding/default/for-await-of-async-func-var-async.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[[23]]]; +})(); + +async function fn() { + for await (var [[] = function() { initCount += 1; }()] of asyncIter) { + assert.sameValue(initCount, 0); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-ary-rest-init.js b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-ary-rest-init.js new file mode 100644 index 0000000000..1748701596 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-ary-rest-init.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-init.case +// - src/dstr-binding/default/for-await-of-async-func-var-async.template +/*--- +description: BindingElement with array binding pattern and initializer is used (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function fn() { + for await (var [[...x] = values] of asyncIter) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-ary-rest-iter.js b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-ary-rest-iter.js new file mode 100644 index 0000000000..e56dde9f13 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-ary-rest-iter.js @@ -0,0 +1,75 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-iter.case +// - src/dstr-binding/default/for-await-of-async-func-var-async.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; +var initCount = 0; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[values]]; +})(); + +async function fn() { + for await (var [[...x] = function() { initCount += 1; }()] of asyncIter) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + assert.sameValue(initCount, 0); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-init-exhausted.js b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-init-exhausted.js new file mode 100644 index 0000000000..1607455627 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-init-exhausted.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-exhausted.case +// - src/dstr-binding/default/for-await-of-async-func-var-async.template +/*--- +description: Destructuring initializer with an exhausted iterator (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function fn() { + for await (var [x = 23] of asyncIter) { + assert.sameValue(x, 23); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-init-fn-name-arrow.js b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..966b522507 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-init-fn-name-arrow.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-arrow.case +// - src/dstr-binding/default/for-await-of-async-func-var-async.template +/*--- +description: SingleNameBinding does assign name to arrow functions (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function fn() { + for await (var [arrow = () => {}] of asyncIter) { + assert.sameValue(arrow.name, 'arrow'); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-init-fn-name-class.js b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-init-fn-name-class.js new file mode 100644 index 0000000000..3b594b8d76 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-init-fn-name-class.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-class.case +// - src/dstr-binding/default/for-await-of-async-func-var-async.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function fn() { + for await (var [cls = class {}, xCls = class X {}, xCls2 = class { static name() {} }] of asyncIter) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + assert.notSameValue(xCls2.name, 'xCls2'); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-init-fn-name-cover.js b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-init-fn-name-cover.js new file mode 100644 index 0000000000..a04e3fe5a6 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-init-fn-name-cover.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-cover.case +// - src/dstr-binding/default/for-await-of-async-func-var-async.template +/*--- +description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function fn() { + for await (var [cover = (function () {}), xCover = (0, function() {})] of asyncIter) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-init-fn-name-fn.js b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-init-fn-name-fn.js new file mode 100644 index 0000000000..030f4a7beb --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-init-fn-name-fn.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-fn.case +// - src/dstr-binding/default/for-await-of-async-func-var-async.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function fn() { + for await (var [fn = function () {}, xFn = function x() {}] of asyncIter) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-init-fn-name-gen.js b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-init-fn-name-gen.js new file mode 100644 index 0000000000..a9ef7113e1 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-init-fn-name-gen.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-gen.case +// - src/dstr-binding/default/for-await-of-async-func-var-async.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function fn() { + for await (var [gen = function* () {}, xGen = function* x() {}] of asyncIter) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-init-hole.js b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-init-hole.js new file mode 100644 index 0000000000..9dc0844557 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-init-hole.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-hole.case +// - src/dstr-binding/default/for-await-of-async-func-var-async.template +/*--- +description: Destructuring initializer with a "hole" (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + SingleNameBinding : BindingIdentifier Initializeropt + [...] 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[,]]; +})(); + +async function fn() { + for await (var [x = 23] of asyncIter) { + assert.sameValue(x, 23); + // another statement + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-init-skipped.js b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-init-skipped.js new file mode 100644 index 0000000000..2e054ddd28 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-init-skipped.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-skipped.case +// - src/dstr-binding/default/for-await-of-async-func-var-async.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[null, 0, false, '']]; +})(); + +async function fn() { + for await (var [w = counter(), x = counter(), y = counter(), z = counter()] of asyncIter) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-init-undef.js b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-init-undef.js new file mode 100644 index 0000000000..119b954088 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-init-undef.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-undef.case +// - src/dstr-binding/default/for-await-of-async-func-var-async.template +/*--- +description: Destructuring initializer with an undefined value (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[undefined]]; +})(); + +async function fn() { + for await (var [x = 23] of asyncIter) { + assert.sameValue(x, 23); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-iter-complete.js b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-iter-complete.js new file mode 100644 index 0000000000..bdf6257fc6 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-iter-complete.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-complete.case +// - src/dstr-binding/default/for-await-of-async-func-var-async.template +/*--- +description: SingleNameBinding when value iteration completes (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function fn() { + for await (var [x] of asyncIter) { + assert.sameValue(x, undefined); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-iter-done.js b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-iter-done.js new file mode 100644 index 0000000000..36f1612d96 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-iter-done.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-done.case +// - src/dstr-binding/default/for-await-of-async-func-var-async.template +/*--- +description: SingleNameBinding when value iteration was completed previously (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function fn() { + for await (var [_, x] of asyncIter) { + assert.sameValue(x, undefined); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-iter-val.js b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-iter-val.js new file mode 100644 index 0000000000..b1991f50da --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-iter-val.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val.case +// - src/dstr-binding/default/for-await-of-async-func-var-async.template +/*--- +description: SingleNameBinding when value iteration was completed previously (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[1, 2, 3]]; +})(); + +async function fn() { + for await (var [x, y, z] of asyncIter) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-obj-id-init.js b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-obj-id-init.js new file mode 100644 index 0000000000..3a5c0567b7 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-obj-id-init.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id-init.case +// - src/dstr-binding/default/for-await-of-async-func-var-async.template +/*--- +description: BindingElement with object binding pattern and initializer is used (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function fn() { + for await (var [{ x, y, z } = { x: 44, y: 55, z: 66 }] of asyncIter) { + assert.sameValue(x, 44); + assert.sameValue(y, 55); + assert.sameValue(z, 66); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-obj-id.js b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-obj-id.js new file mode 100644 index 0000000000..77989c0c5f --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-obj-id.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id.case +// - src/dstr-binding/default/for-await-of-async-func-var-async.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[{ x: 11, y: 22, z: 33 }]]; +})(); + +async function fn() { + for await (var [{ x, y, z } = { x: 44, y: 55, z: 66 }] of asyncIter) { + assert.sameValue(x, 11); + assert.sameValue(y, 22); + assert.sameValue(z, 33); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-obj-prop-id-init.js b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-obj-prop-id-init.js new file mode 100644 index 0000000000..7b2bdf870f --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-obj-prop-id-init.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id-init.case +// - src/dstr-binding/default/for-await-of-async-func-var-async.template +/*--- +description: BindingElement with object binding pattern and initializer is used (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function fn() { + for await (var [{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] of asyncIter) { + assert.sameValue(v, 444); + assert.sameValue(x, 555); + assert.sameValue(z, 666); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-obj-prop-id.js b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-obj-prop-id.js new file mode 100644 index 0000000000..3b3205f6ac --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-obj-prop-id.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id.case +// - src/dstr-binding/default/for-await-of-async-func-var-async.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[{ u: 777, w: 888, y: 999 }]]; +})(); + +async function fn() { + for await (var [{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] of asyncIter) { + assert.sameValue(v, 777); + assert.sameValue(x, 888); + assert.sameValue(z, 999); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elision-exhausted.js b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elision-exhausted.js new file mode 100644 index 0000000000..c2a92d6b19 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elision-exhausted.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-exhausted.case +// - src/dstr-binding/default/for-await-of-async-func-var-async.template +/*--- +description: Elision accepts exhausted iterator (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [generator, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + [...] + 2. Return NormalCompletion(empty). + +---*/ +var iter = function*() {}(); +iter.next(); + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [iter]; +})(); + +async function fn() { + for await (var [,] of asyncIter) { + + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elision.js b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elision.js new file mode 100644 index 0000000000..b214ab9540 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elision.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision.case +// - src/dstr-binding/default/for-await-of-async-func-var-async.template +/*--- +description: Elision advances iterator (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [generator, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [g()]; +})(); + +async function fn() { + for await (var [,] of asyncIter) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-empty.js b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-empty.js new file mode 100644 index 0000000000..6eb948798f --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-empty.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-empty.case +// - src/dstr-binding/default/for-await-of-async-func-var-async.template +/*--- +description: No iteration occurs for an "empty" array binding pattern (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [generators, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [iter]; +})(); + +async function fn() { + for await (var [] of asyncIter) { + assert.sameValue(iterations, 0); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-ary-elem.js b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-ary-elem.js new file mode 100644 index 0000000000..cb8f1355f1 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-ary-elem.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elem.case +// - src/dstr-binding/default/for-await-of-async-func-var-async.template +/*--- +description: Rest element containing an array BindingElementList pattern (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[3, 4, 5]]; +})(); + +async function fn() { + for await (var [...[x, y, z]] of asyncIter) { + assert.sameValue(x, 3); + assert.sameValue(y, 4); + assert.sameValue(z, 5); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-ary-elision.js b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-ary-elision.js new file mode 100644 index 0000000000..fc9285fc58 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-ary-elision.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elision.case +// - src/dstr-binding/default/for-await-of-async-func-var-async.template +/*--- +description: Rest element containing an elision (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [generators, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [g()]; +})(); + +async function fn() { + for await (var [...[,]] of asyncIter) { + assert.sameValue(first, 1); + assert.sameValue(second, 1); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-ary-empty.js b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-ary-empty.js new file mode 100644 index 0000000000..d4523026b0 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-ary-empty.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-empty.case +// - src/dstr-binding/default/for-await-of-async-func-var-async.template +/*--- +description: Rest element containing an "empty" array pattern (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [generators, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [iter]; +})(); + +async function fn() { + for await (var [...[]] of asyncIter) { + assert.sameValue(iterations, 1); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-ary-rest.js b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-ary-rest.js new file mode 100644 index 0000000000..676d705266 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-ary-rest.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-rest.case +// - src/dstr-binding/default/for-await-of-async-func-var-async.template +/*--- +description: Rest element containing a rest element (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +var values = [1, 2, 3]; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [values]; +})(); + +async function fn() { + for await (var [...[...x]] of asyncIter) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-id-elision.js b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-id-elision.js new file mode 100644 index 0000000000..671542740d --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-id-elision.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision.case +// - src/dstr-binding/default/for-await-of-async-func-var-async.template +/*--- +description: Rest element following elision elements (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. +---*/ +var values = [1, 2, 3, 4, 5]; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [values]; +})(); + +async function fn() { + for await (var [ , , ...x] of asyncIter) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 3); + assert.sameValue(x[1], 4); + assert.sameValue(x[2], 5); + assert.notSameValue(x, values); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-id-exhausted.js b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-id-exhausted.js new file mode 100644 index 0000000000..29dab2740e --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-id-exhausted.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-exhausted.case +// - src/dstr-binding/default/for-await-of-async-func-var-async.template +/*--- +description: RestElement applied to an exhausted iterator (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [Symbol.iterator, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + b. If iteratorRecord.[[done]] is true, then + i. If environment is undefined, return PutValue(lhs, A). + ii. Return InitializeReferencedBinding(lhs, A). + +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[1, 2]]; +})(); + +async function fn() { + for await (var [, , ...x] of asyncIter) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 0); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-id.js b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-id.js new file mode 100644 index 0000000000..34e1663c23 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-id.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id.case +// - src/dstr-binding/default/for-await-of-async-func-var-async.template +/*--- +description: Lone rest element (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat + [...] + f. Let status be CreateDataProperty(A, ToString (n), nextValue). + [...] +---*/ +var values = [1, 2, 3]; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [values]; +})(); + +async function fn() { + for await (var [...x] of asyncIter) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-init-ary.js b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-init-ary.js new file mode 100644 index 0000000000..c6999d3578 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-init-ary.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-ary.case +// - src/dstr-binding/default/for-await-of-async-func-var-async.template +/*--- +description: Reset element (nested array pattern) does not support initializer (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +negative: + phase: early + type: SyntaxError +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function fn() { + for await (var [...[ x ] = []] of asyncIter) { + + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-init-id.js b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-init-id.js new file mode 100644 index 0000000000..e9aafea0ef --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-init-id.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-id.case +// - src/dstr-binding/default/for-await-of-async-func-var-async.template +/*--- +description: Reset element (identifier) does not support initializer (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +negative: + phase: early + type: SyntaxError +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function fn() { + for await (var [...x = []] of asyncIter) { + + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-init-obj.js b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-init-obj.js new file mode 100644 index 0000000000..fb517fa378 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-init-obj.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-obj.case +// - src/dstr-binding/default/for-await-of-async-func-var-async.template +/*--- +description: Reset element (nested object pattern) does not support initializer (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +negative: + phase: early + type: SyntaxError +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function fn() { + for await (var [...{ x } = []] of asyncIter) { + + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-not-final-ary.js b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-not-final-ary.js new file mode 100644 index 0000000000..ffe7b062dc --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-not-final-ary.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-ary.case +// - src/dstr-binding/default/for-await-of-async-func-var-async.template +/*--- +description: Rest element (array binding pattern) may not be followed by any element (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +negative: + phase: early + type: SyntaxError +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[1, 2, 3]]; +})(); + +async function fn() { + for await (var [...[x], y] of asyncIter) { + + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-not-final-id.js b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-not-final-id.js new file mode 100644 index 0000000000..539c7701ac --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-not-final-id.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-id.case +// - src/dstr-binding/default/for-await-of-async-func-var-async.template +/*--- +description: Rest element (identifier) may not be followed by any element (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +negative: + phase: early + type: SyntaxError +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[1, 2, 3]]; +})(); + +async function fn() { + for await (var [...x, y] of asyncIter) { + + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-not-final-obj.js b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-not-final-obj.js new file mode 100644 index 0000000000..87e714cee0 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-not-final-obj.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-obj.case +// - src/dstr-binding/default/for-await-of-async-func-var-async.template +/*--- +description: Rest element (object binding pattern) may not be followed by any element (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +negative: + phase: early + type: SyntaxError +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[1, 2, 3]]; +})(); + +async function fn() { + for await (var [...{ x }, y] of asyncIter) { + + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-obj-id.js b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-obj-id.js new file mode 100644 index 0000000000..616cac3882 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-obj-id.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-id.case +// - src/dstr-binding/default/for-await-of-async-func-var-async.template +/*--- +description: Rest element containing an object binding pattern (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[1, 2, 3]]; +})(); + +async function fn() { + for await (var [...{ length }] of asyncIter) { + assert.sameValue(length, 3); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-obj-prop-id.js b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-obj-prop-id.js new file mode 100644 index 0000000000..f224e00219 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-obj-prop-id.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-prop-id.case +// - src/dstr-binding/default/for-await-of-async-func-var-async.template +/*--- +description: Rest element containing an object binding pattern (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +let length = "outer"; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[7, 8, 9]]; +})(); + +async function fn() { + for await (var [...{ 0: v, 1: w, 2: x, 3: y, length: z }] of asyncIter) { + assert.sameValue(v, 7); + assert.sameValue(w, 8); + assert.sameValue(x, 9); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + assert.sameValue(length, "outer", "the length prop is not set as a binding name"); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-empty.js b/test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-empty.js new file mode 100644 index 0000000000..50635bff9f --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-empty.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-empty.case +// - src/dstr-binding/default/for-await-of-async-func-var-async.template +/*--- +description: No property access occurs for an "empty" object binding pattern (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ +var accessCount = 0; +var obj = Object.defineProperty({}, 'attr', { + get: function() { + accessCount += 1; + } +}); + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [obj]; +})(); + +async function fn() { + for await (var {} of asyncIter) { + assert.sameValue(accessCount, 0); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-id-init-fn-name-arrow.js b/test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..12cec7f4ec --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-id-init-fn-name-arrow.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-arrow.case +// - src/dstr-binding/default/for-await-of-async-func-var-async.template +/*--- +description: SingleNameBinding assigns `name` to arrow functions (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{}]; +})(); + +async function fn() { + for await (var { arrow = () => {} } of asyncIter) { + assert.sameValue(arrow.name, 'arrow'); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-id-init-fn-name-class.js b/test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-id-init-fn-name-class.js new file mode 100644 index 0000000000..aee417404b --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-id-init-fn-name-class.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-class.case +// - src/dstr-binding/default/for-await-of-async-func-var-async.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{}]; +})(); + +async function fn() { + for await (var { cls = class {}, xCls = class X {}, xCls2 = class { static name() {} } } of asyncIter) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + assert.notSameValue(xCls2.name, 'xCls2'); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-id-init-fn-name-cover.js b/test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-id-init-fn-name-cover.js new file mode 100644 index 0000000000..a09c6b646d --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-id-init-fn-name-cover.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-cover.case +// - src/dstr-binding/default/for-await-of-async-func-var-async.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{}]; +})(); + +async function fn() { + for await (var { cover = (function () {}), xCover = (0, function() {}) } of asyncIter) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-id-init-fn-name-fn.js b/test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-id-init-fn-name-fn.js new file mode 100644 index 0000000000..96a25c8d93 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-id-init-fn-name-fn.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-fn.case +// - src/dstr-binding/default/for-await-of-async-func-var-async.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{}]; +})(); + +async function fn() { + for await (var { fn = function () {}, xFn = function x() {} } of asyncIter) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-id-init-fn-name-gen.js b/test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-id-init-fn-name-gen.js new file mode 100644 index 0000000000..a7747873cc --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-id-init-fn-name-gen.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-gen.case +// - src/dstr-binding/default/for-await-of-async-func-var-async.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{}]; +})(); + +async function fn() { + for await (var { gen = function* () {}, xGen = function* x() {} } of asyncIter) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-id-init-skipped.js b/test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-id-init-skipped.js new file mode 100644 index 0000000000..f92c695c1f --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-id-init-skipped.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-skipped.case +// - src/dstr-binding/default/for-await-of-async-func-var-async.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{ w: null, x: 0, y: false, z: '' }]; +})(); + +async function fn() { + for await (var { w = counter(), x = counter(), y = counter(), z = counter() } of asyncIter) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-id-trailing-comma.js b/test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-id-trailing-comma.js new file mode 100644 index 0000000000..35d763515f --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-id-trailing-comma.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-trailing-comma.case +// - src/dstr-binding/default/for-await-of-async-func-var-async.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{ x: 23 }]; +})(); + +async function fn() { + for await (var { x, } of asyncIter) { + assert.sameValue(x, 23); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-prop-ary-init.js b/test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-prop-ary-init.js new file mode 100644 index 0000000000..835b4ac563 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-prop-ary-init.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-init.case +// - src/dstr-binding/default/for-await-of-async-func-var-async.template +/*--- +description: Object binding pattern with "nested" array binding pattern using initializer (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{}]; +})(); + +async function fn() { + for await (var { w: [x, y, z] = [4, 5, 6] } of asyncIter) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-prop-ary-trailing-comma.js b/test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-prop-ary-trailing-comma.js new file mode 100644 index 0000000000..7afeb0dcdf --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-prop-ary-trailing-comma.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-trailing-comma.case +// - src/dstr-binding/default/for-await-of-async-func-var-async.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{ x: [45] }]; +})(); + +async function fn() { + for await (var { x: [y], } of asyncIter) { + assert.sameValue(y,45); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-prop-ary.js b/test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-prop-ary.js new file mode 100644 index 0000000000..719d73f6a6 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-prop-ary.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary.case +// - src/dstr-binding/default/for-await-of-async-func-var-async.template +/*--- +description: Object binding pattern with "nested" array binding pattern not using initializer (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{ w: [7, undefined, ] }]; +})(); + +async function fn() { + for await (var { w: [x, y, z] = [4, 5, 6] } of asyncIter) { + assert.sameValue(x, 7); + assert.sameValue(y, undefined); + assert.sameValue(z, undefined); + + assert.throws(ReferenceError, function() { + w; + }); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-prop-id-init-skipped.js b/test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-prop-id-init-skipped.js new file mode 100644 index 0000000000..118c1d010a --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-prop-id-init-skipped.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case +// - src/dstr-binding/default/for-await-of-async-func-var-async.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{ s: null, u: 0, w: false, y: '' }]; +})(); + +async function fn() { + for await (var { s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() } of asyncIter) { + assert.sameValue(t, null); + assert.sameValue(v, 0); + assert.sameValue(x, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + assert.throws(ReferenceError, function() { + s; + }); + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-prop-id-init.js b/test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-prop-id-init.js new file mode 100644 index 0000000000..eee0d11bb4 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-prop-id-init.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init.case +// - src/dstr-binding/default/for-await-of-async-func-var-async.template +/*--- +description: Binding as specified via property name, identifier, and initializer (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{ }]; +})(); + +async function fn() { + for await (var { x: y = 33 } of asyncIter) { + assert.sameValue(y, 33); + assert.throws(ReferenceError, function() { + x; + }); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-prop-id-trailing-comma.js b/test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-prop-id-trailing-comma.js new file mode 100644 index 0000000000..ff706f64f3 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-prop-id-trailing-comma.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-trailing-comma.case +// - src/dstr-binding/default/for-await-of-async-func-var-async.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{ x: 23 }]; +})(); + +async function fn() { + for await (var { x: y, } of asyncIter) { + assert.sameValue(y, 23); + + assert.throws(ReferenceError, function() { + x; + }); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-prop-id.js b/test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-prop-id.js new file mode 100644 index 0000000000..d060f1b30f --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-prop-id.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id.case +// - src/dstr-binding/default/for-await-of-async-func-var-async.template +/*--- +description: Binding as specified via property name and identifier (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{ x: 23 }]; +})(); + +async function fn() { + for await (var { x: y } of asyncIter) { + assert.sameValue(y, 23); + assert.throws(ReferenceError, function() { + x; + }); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-prop-obj-init.js b/test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-prop-obj-init.js new file mode 100644 index 0000000000..a62f5955c2 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-prop-obj-init.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-init.case +// - src/dstr-binding/default/for-await-of-async-func-var-async.template +/*--- +description: Object binding pattern with "nested" object binding pattern using initializer (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{ w: undefined }]; +})(); + +async function fn() { + for await (var { w: { x, y, z } = { x: 4, y: 5, z: 6 } } of asyncIter) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-prop-obj.js b/test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-prop-obj.js new file mode 100644 index 0000000000..f531e0e7f3 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-prop-obj.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj.case +// - src/dstr-binding/default/for-await-of-async-func-var-async.template +/*--- +description: Object binding pattern with "nested" object binding pattern not using initializer (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{ w: { x: undefined, z: 7 } }]; +})(); + +async function fn() { + for await (var { w: { x, y, z } = { x: 4, y: 5, z: 6 } } of asyncIter) { + assert.sameValue(x, undefined); + assert.sameValue(y, undefined); + assert.sameValue(z, 7); + + assert.throws(ReferenceError, function() { + w; + }); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-rest-getter.js b/test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-rest-getter.js new file mode 100644 index 0000000000..0e3f879f3a --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-rest-getter.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-getter.case +// - src/dstr-binding/default/for-await-of-async-func-var-async.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [object-rest, destructuring-binding, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] +---*/ +var count = 0; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{ get v() { count++; return 2; } }]; +})(); + +async function fn() { + for await (var {...x} of asyncIter) { + assert.sameValue(x.v, 2); + assert.sameValue(count, 1); + + verifyEnumerable(x, "v"); + verifyWritable(x, "v"); + verifyConfigurable(x, "v"); + + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-rest-nested-obj.js b/test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-rest-nested-obj.js new file mode 100644 index 0000000000..2741c5fc7d --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-rest-nested-obj.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-nested-obj.case +// - src/dstr-binding/default/for-await-of-async-func-var-async.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment. (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [object-rest, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] +---*/ +var obj = {a: 3, b: 4}; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{a: 1, b: 2, c: 3, d: 4, e: 5}]; +})(); + +async function fn() { + for await (var {a, b, ...{c, e}} of asyncIter) { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + assert.sameValue(e, 5); + + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-rest-obj-nested-rest.js b/test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-rest-obj-nested-rest.js new file mode 100644 index 0000000000..f675813c1b --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-rest-obj-nested-rest.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-nested-rest.case +// - src/dstr-binding/default/for-await-of-async-func-var-async.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment and object rest desconstruction is allowed in that case. (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [object-rest, destructuring-binding, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{a: 1, b: 2, c: 3, d: 4, e: 5}]; +})(); + +async function fn() { + for await (var {a, b, ...{c, ...rest}} of asyncIter) { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + + assert.sameValue(rest.d, 4); + assert.sameValue(rest.e, 5); + + verifyEnumerable(rest, "d"); + verifyWritable(rest, "d"); + verifyConfigurable(rest, "d"); + + verifyEnumerable(rest, "e"); + verifyWritable(rest, "e"); + verifyConfigurable(rest, "e"); + + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-rest-obj-own-property.js b/test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-rest-obj-own-property.js new file mode 100644 index 0000000000..c02173fbca --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-rest-obj-own-property.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-own-property.case +// - src/dstr-binding/default/for-await-of-async-func-var-async.template +/*--- +description: Rest object contains just soruce object's own properties (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [object-rest, destructuring-binding, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] +---*/ +var o = Object.create({ x: 1, y: 2 }); +o.z = 3; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [o]; +})(); + +async function fn() { + for await (var { x, ...{y , z} } of asyncIter) { + assert.sameValue(x, 1); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-rest-skip-non-enumerable.js b/test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..2f914454a9 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-rest-skip-non-enumerable.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-skip-non-enumerable.case +// - src/dstr-binding/default/for-await-of-async-func-var-async.template +/*--- +description: Rest object doesn't contain non-enumerable properties (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [object-rest, destructuring-binding, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] +---*/ +var o = {a: 3, b: 4}; +Object.defineProperty(o, "x", { value: 4, enumerable: false }); + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [o]; +})(); + +async function fn() { + for await (var {...rest} of asyncIter) { + assert.sameValue(rest.a, 3); + assert.sameValue(rest.b, 4); + assert.sameValue(rest.x, undefined); + + verifyEnumerable(rest, "a"); + verifyWritable(rest, "a"); + verifyConfigurable(rest, "a"); + + verifyEnumerable(rest, "b"); + verifyWritable(rest, "b"); + verifyConfigurable(rest, "b"); + + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-rest-val-obj.js b/test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-rest-val-obj.js new file mode 100644 index 0000000000..87edd0d287 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-rest-val-obj.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-val-obj.case +// - src/dstr-binding/default/for-await-of-async-func-var-async.template +/*--- +description: Rest object contains just unextracted data (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [object-rest, destructuring-binding, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{x: 1, y: 2, a: 5, b: 3}]; +})(); + +async function fn() { + for await (var {a, b, ...rest} of asyncIter) { + assert.sameValue(rest.x, 1); + assert.sameValue(rest.y, 2); + assert.sameValue(rest.a, undefined); + assert.sameValue(rest.b, undefined); + + verifyEnumerable(rest, "x"); + verifyWritable(rest, "x"); + verifyConfigurable(rest, "x"); + + verifyEnumerable(rest, "y"); + verifyWritable(rest, "y"); + verifyConfigurable(rest, "y"); + + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-init-iter-close.js b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-init-iter-close.js new file mode 100644 index 0000000000..94d5b939ea --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-init-iter-close.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-close.case +// - src/dstr-binding/default/for-await-of-async-gen-const-async.template +/*--- +description: Iterator is closed when not exhausted by pattern evaluation (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [Symbol.iterator, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: false }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [iter]; +})(); + +async function *fn() { + for await (const [x] of asyncIter) { + assert.sameValue(doneCallCount, 1); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-init-iter-no-close.js b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-init-iter-no-close.js new file mode 100644 index 0000000000..6fa1d2c066 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-init-iter-no-close.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-no-close.case +// - src/dstr-binding/default/for-await-of-async-gen-const-async.template +/*--- +description: Iterator is not closed when exhausted by pattern evaluation (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [Symbol.iterator, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: true }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [iter]; +})(); + +async function *fn() { + for await (const [x] of asyncIter) { + assert.sameValue(doneCallCount, 0); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-name-iter-val.js b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-name-iter-val.js new file mode 100644 index 0000000000..73d3a0b51a --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-name-iter-val.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-name-iter-val.case +// - src/dstr-binding/default/for-await-of-async-gen-const-async.template +/*--- +description: SingleNameBinding with normal value iteration (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[1, 2, 3]]; +})(); + +async function *fn() { + for await (const [x, y, z] of asyncIter) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-ary-elem-init.js b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-ary-elem-init.js new file mode 100644 index 0000000000..a3a5fc455c --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-ary-elem-init.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-init.case +// - src/dstr-binding/default/for-await-of-async-gen-const-async.template +/*--- +description: BindingElement with array binding pattern and initializer is used (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function *fn() { + for await (const [[x, y, z] = [4, 5, 6]] of asyncIter) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-ary-elem-iter.js b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-ary-elem-iter.js new file mode 100644 index 0000000000..d35829005e --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-ary-elem-iter.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-iter.case +// - src/dstr-binding/default/for-await-of-async-gen-const-async.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[[7, 8, 9]]]; +})(); + +async function *fn() { + for await (const [[x, y, z] = [4, 5, 6]] of asyncIter) { + assert.sameValue(x, 7); + assert.sameValue(y, 8); + assert.sameValue(z, 9); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-ary-elision-init.js b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-ary-elision-init.js new file mode 100644 index 0000000000..82ced4fd9f --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-ary-elision-init.js @@ -0,0 +1,75 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case +// - src/dstr-binding/default/for-await-of-async-gen-const-async.template +/*--- +description: BindingElement with array binding pattern and initializer is used (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [generators, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function *fn() { + for await (const [[,] = g()] of asyncIter) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-ary-elision-iter.js b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-ary-elision-iter.js new file mode 100644 index 0000000000..76e27d6642 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-ary-elision-iter.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-iter.case +// - src/dstr-binding/default/for-await-of-async-gen-const-async.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [generators, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var callCount = 0; +function* g() { + callCount += 1; +}; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[[]]]; +})(); + +async function *fn() { + for await (const [[,] = g()] of asyncIter) { + assert.sameValue(callCount, 0); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-ary-empty-init.js b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-ary-empty-init.js new file mode 100644 index 0000000000..a32f0d12f0 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-ary-empty-init.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-init.case +// - src/dstr-binding/default/for-await-of-async-gen-const-async.template +/*--- +description: BindingElement with array binding pattern and initializer is used (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; +var iterCount = 0; +var iter = function*() { iterCount += 1; }(); + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function *fn() { + for await (const [[] = function() { initCount += 1; return iter; }()] of asyncIter) { + assert.sameValue(initCount, 1); + assert.sameValue(iterCount, 0); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-ary-empty-iter.js b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-ary-empty-iter.js new file mode 100644 index 0000000000..5952154252 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-ary-empty-iter.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-iter.case +// - src/dstr-binding/default/for-await-of-async-gen-const-async.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[[23]]]; +})(); + +async function *fn() { + for await (const [[] = function() { initCount += 1; }()] of asyncIter) { + assert.sameValue(initCount, 0); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-ary-rest-init.js b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-ary-rest-init.js new file mode 100644 index 0000000000..1c2c909982 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-ary-rest-init.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-init.case +// - src/dstr-binding/default/for-await-of-async-gen-const-async.template +/*--- +description: BindingElement with array binding pattern and initializer is used (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function *fn() { + for await (const [[...x] = values] of asyncIter) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-ary-rest-iter.js b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-ary-rest-iter.js new file mode 100644 index 0000000000..bee246f414 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-ary-rest-iter.js @@ -0,0 +1,75 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-iter.case +// - src/dstr-binding/default/for-await-of-async-gen-const-async.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; +var initCount = 0; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[values]]; +})(); + +async function *fn() { + for await (const [[...x] = function() { initCount += 1; }()] of asyncIter) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + assert.sameValue(initCount, 0); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-init-exhausted.js b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-init-exhausted.js new file mode 100644 index 0000000000..8c17b68f41 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-init-exhausted.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-exhausted.case +// - src/dstr-binding/default/for-await-of-async-gen-const-async.template +/*--- +description: Destructuring initializer with an exhausted iterator (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function *fn() { + for await (const [x = 23] of asyncIter) { + assert.sameValue(x, 23); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-init-fn-name-arrow.js b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..1977874a42 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-init-fn-name-arrow.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-arrow.case +// - src/dstr-binding/default/for-await-of-async-gen-const-async.template +/*--- +description: SingleNameBinding does assign name to arrow functions (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function *fn() { + for await (const [arrow = () => {}] of asyncIter) { + assert.sameValue(arrow.name, 'arrow'); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-init-fn-name-class.js b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-init-fn-name-class.js new file mode 100644 index 0000000000..d60c465b2b --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-init-fn-name-class.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-class.case +// - src/dstr-binding/default/for-await-of-async-gen-const-async.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function *fn() { + for await (const [cls = class {}, xCls = class X {}, xCls2 = class { static name() {} }] of asyncIter) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + assert.notSameValue(xCls2.name, 'xCls2'); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-init-fn-name-cover.js b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-init-fn-name-cover.js new file mode 100644 index 0000000000..586ee276ad --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-init-fn-name-cover.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-cover.case +// - src/dstr-binding/default/for-await-of-async-gen-const-async.template +/*--- +description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function *fn() { + for await (const [cover = (function () {}), xCover = (0, function() {})] of asyncIter) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-init-fn-name-fn.js b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-init-fn-name-fn.js new file mode 100644 index 0000000000..bf6f1e2b7c --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-init-fn-name-fn.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-fn.case +// - src/dstr-binding/default/for-await-of-async-gen-const-async.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function *fn() { + for await (const [fn = function () {}, xFn = function x() {}] of asyncIter) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-init-fn-name-gen.js b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-init-fn-name-gen.js new file mode 100644 index 0000000000..3ca26a31e0 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-init-fn-name-gen.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-gen.case +// - src/dstr-binding/default/for-await-of-async-gen-const-async.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function *fn() { + for await (const [gen = function* () {}, xGen = function* x() {}] of asyncIter) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-init-hole.js b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-init-hole.js new file mode 100644 index 0000000000..b8211c42bf --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-init-hole.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-hole.case +// - src/dstr-binding/default/for-await-of-async-gen-const-async.template +/*--- +description: Destructuring initializer with a "hole" (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + SingleNameBinding : BindingIdentifier Initializeropt + [...] 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[,]]; +})(); + +async function *fn() { + for await (const [x = 23] of asyncIter) { + assert.sameValue(x, 23); + // another statement + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-init-skipped.js b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-init-skipped.js new file mode 100644 index 0000000000..bd3ab2b97b --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-init-skipped.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-skipped.case +// - src/dstr-binding/default/for-await-of-async-gen-const-async.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[null, 0, false, '']]; +})(); + +async function *fn() { + for await (const [w = counter(), x = counter(), y = counter(), z = counter()] of asyncIter) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-init-undef.js b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-init-undef.js new file mode 100644 index 0000000000..3c2e209c9b --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-init-undef.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-undef.case +// - src/dstr-binding/default/for-await-of-async-gen-const-async.template +/*--- +description: Destructuring initializer with an undefined value (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[undefined]]; +})(); + +async function *fn() { + for await (const [x = 23] of asyncIter) { + assert.sameValue(x, 23); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-iter-complete.js b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-iter-complete.js new file mode 100644 index 0000000000..3f7ff1017c --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-iter-complete.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-complete.case +// - src/dstr-binding/default/for-await-of-async-gen-const-async.template +/*--- +description: SingleNameBinding when value iteration completes (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function *fn() { + for await (const [x] of asyncIter) { + assert.sameValue(x, undefined); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-iter-done.js b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-iter-done.js new file mode 100644 index 0000000000..96730f7f3d --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-iter-done.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-done.case +// - src/dstr-binding/default/for-await-of-async-gen-const-async.template +/*--- +description: SingleNameBinding when value iteration was completed previously (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function *fn() { + for await (const [_, x] of asyncIter) { + assert.sameValue(x, undefined); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-iter-val.js b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-iter-val.js new file mode 100644 index 0000000000..0192acef77 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-iter-val.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val.case +// - src/dstr-binding/default/for-await-of-async-gen-const-async.template +/*--- +description: SingleNameBinding when value iteration was completed previously (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[1, 2, 3]]; +})(); + +async function *fn() { + for await (const [x, y, z] of asyncIter) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-obj-id-init.js b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-obj-id-init.js new file mode 100644 index 0000000000..17b6913d49 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-obj-id-init.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id-init.case +// - src/dstr-binding/default/for-await-of-async-gen-const-async.template +/*--- +description: BindingElement with object binding pattern and initializer is used (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function *fn() { + for await (const [{ x, y, z } = { x: 44, y: 55, z: 66 }] of asyncIter) { + assert.sameValue(x, 44); + assert.sameValue(y, 55); + assert.sameValue(z, 66); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-obj-id.js b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-obj-id.js new file mode 100644 index 0000000000..e495d3ecb7 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-obj-id.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id.case +// - src/dstr-binding/default/for-await-of-async-gen-const-async.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[{ x: 11, y: 22, z: 33 }]]; +})(); + +async function *fn() { + for await (const [{ x, y, z } = { x: 44, y: 55, z: 66 }] of asyncIter) { + assert.sameValue(x, 11); + assert.sameValue(y, 22); + assert.sameValue(z, 33); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-obj-prop-id-init.js b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-obj-prop-id-init.js new file mode 100644 index 0000000000..7257b001d0 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-obj-prop-id-init.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id-init.case +// - src/dstr-binding/default/for-await-of-async-gen-const-async.template +/*--- +description: BindingElement with object binding pattern and initializer is used (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function *fn() { + for await (const [{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] of asyncIter) { + assert.sameValue(v, 444); + assert.sameValue(x, 555); + assert.sameValue(z, 666); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-obj-prop-id.js b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-obj-prop-id.js new file mode 100644 index 0000000000..c19221c92c --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-obj-prop-id.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id.case +// - src/dstr-binding/default/for-await-of-async-gen-const-async.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[{ u: 777, w: 888, y: 999 }]]; +})(); + +async function *fn() { + for await (const [{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] of asyncIter) { + assert.sameValue(v, 777); + assert.sameValue(x, 888); + assert.sameValue(z, 999); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elision-exhausted.js b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elision-exhausted.js new file mode 100644 index 0000000000..2af9650914 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elision-exhausted.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-exhausted.case +// - src/dstr-binding/default/for-await-of-async-gen-const-async.template +/*--- +description: Elision accepts exhausted iterator (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [generator, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + [...] + 2. Return NormalCompletion(empty). + +---*/ +var iter = function*() {}(); +iter.next(); + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [iter]; +})(); + +async function *fn() { + for await (const [,] of asyncIter) { + + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elision.js b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elision.js new file mode 100644 index 0000000000..b6d981909a --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elision.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision.case +// - src/dstr-binding/default/for-await-of-async-gen-const-async.template +/*--- +description: Elision advances iterator (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [generator, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [g()]; +})(); + +async function *fn() { + for await (const [,] of asyncIter) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-empty.js b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-empty.js new file mode 100644 index 0000000000..c562e057ac --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-empty.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-empty.case +// - src/dstr-binding/default/for-await-of-async-gen-const-async.template +/*--- +description: No iteration occurs for an "empty" array binding pattern (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [generators, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [iter]; +})(); + +async function *fn() { + for await (const [] of asyncIter) { + assert.sameValue(iterations, 0); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-ary-elem.js b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-ary-elem.js new file mode 100644 index 0000000000..45086a2ec1 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-ary-elem.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elem.case +// - src/dstr-binding/default/for-await-of-async-gen-const-async.template +/*--- +description: Rest element containing an array BindingElementList pattern (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[3, 4, 5]]; +})(); + +async function *fn() { + for await (const [...[x, y, z]] of asyncIter) { + assert.sameValue(x, 3); + assert.sameValue(y, 4); + assert.sameValue(z, 5); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-ary-elision.js b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-ary-elision.js new file mode 100644 index 0000000000..661c0a4c8b --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-ary-elision.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elision.case +// - src/dstr-binding/default/for-await-of-async-gen-const-async.template +/*--- +description: Rest element containing an elision (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [generators, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [g()]; +})(); + +async function *fn() { + for await (const [...[,]] of asyncIter) { + assert.sameValue(first, 1); + assert.sameValue(second, 1); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-ary-empty.js b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-ary-empty.js new file mode 100644 index 0000000000..be4dac13fc --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-ary-empty.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-empty.case +// - src/dstr-binding/default/for-await-of-async-gen-const-async.template +/*--- +description: Rest element containing an "empty" array pattern (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [generators, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [iter]; +})(); + +async function *fn() { + for await (const [...[]] of asyncIter) { + assert.sameValue(iterations, 1); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-ary-rest.js b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-ary-rest.js new file mode 100644 index 0000000000..2b44ec30e0 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-ary-rest.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-rest.case +// - src/dstr-binding/default/for-await-of-async-gen-const-async.template +/*--- +description: Rest element containing a rest element (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +var values = [1, 2, 3]; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [values]; +})(); + +async function *fn() { + for await (const [...[...x]] of asyncIter) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-id-elision.js b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-id-elision.js new file mode 100644 index 0000000000..7fdcd7119a --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-id-elision.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision.case +// - src/dstr-binding/default/for-await-of-async-gen-const-async.template +/*--- +description: Rest element following elision elements (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. +---*/ +var values = [1, 2, 3, 4, 5]; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [values]; +})(); + +async function *fn() { + for await (const [ , , ...x] of asyncIter) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 3); + assert.sameValue(x[1], 4); + assert.sameValue(x[2], 5); + assert.notSameValue(x, values); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-id-exhausted.js b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-id-exhausted.js new file mode 100644 index 0000000000..e8417f5ad0 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-id-exhausted.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-exhausted.case +// - src/dstr-binding/default/for-await-of-async-gen-const-async.template +/*--- +description: RestElement applied to an exhausted iterator (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [Symbol.iterator, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + b. If iteratorRecord.[[done]] is true, then + i. If environment is undefined, return PutValue(lhs, A). + ii. Return InitializeReferencedBinding(lhs, A). + +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[1, 2]]; +})(); + +async function *fn() { + for await (const [, , ...x] of asyncIter) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 0); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-id.js b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-id.js new file mode 100644 index 0000000000..0d991672b4 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-id.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id.case +// - src/dstr-binding/default/for-await-of-async-gen-const-async.template +/*--- +description: Lone rest element (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat + [...] + f. Let status be CreateDataProperty(A, ToString (n), nextValue). + [...] +---*/ +var values = [1, 2, 3]; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [values]; +})(); + +async function *fn() { + for await (const [...x] of asyncIter) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-init-ary.js b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-init-ary.js new file mode 100644 index 0000000000..685341687c --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-init-ary.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-ary.case +// - src/dstr-binding/default/for-await-of-async-gen-const-async.template +/*--- +description: Reset element (nested array pattern) does not support initializer (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +negative: + phase: early + type: SyntaxError +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function *fn() { + for await (const [...[ x ] = []] of asyncIter) { + + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-init-id.js b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-init-id.js new file mode 100644 index 0000000000..b4e256e6a7 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-init-id.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-id.case +// - src/dstr-binding/default/for-await-of-async-gen-const-async.template +/*--- +description: Reset element (identifier) does not support initializer (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +negative: + phase: early + type: SyntaxError +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function *fn() { + for await (const [...x = []] of asyncIter) { + + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-init-obj.js b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-init-obj.js new file mode 100644 index 0000000000..405d946ee3 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-init-obj.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-obj.case +// - src/dstr-binding/default/for-await-of-async-gen-const-async.template +/*--- +description: Reset element (nested object pattern) does not support initializer (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +negative: + phase: early + type: SyntaxError +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function *fn() { + for await (const [...{ x } = []] of asyncIter) { + + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-not-final-ary.js b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-not-final-ary.js new file mode 100644 index 0000000000..2a62d2e5a4 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-not-final-ary.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-ary.case +// - src/dstr-binding/default/for-await-of-async-gen-const-async.template +/*--- +description: Rest element (array binding pattern) may not be followed by any element (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +negative: + phase: early + type: SyntaxError +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[1, 2, 3]]; +})(); + +async function *fn() { + for await (const [...[x], y] of asyncIter) { + + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-not-final-id.js b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-not-final-id.js new file mode 100644 index 0000000000..fb0fff162d --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-not-final-id.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-id.case +// - src/dstr-binding/default/for-await-of-async-gen-const-async.template +/*--- +description: Rest element (identifier) may not be followed by any element (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +negative: + phase: early + type: SyntaxError +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[1, 2, 3]]; +})(); + +async function *fn() { + for await (const [...x, y] of asyncIter) { + + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-not-final-obj.js b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-not-final-obj.js new file mode 100644 index 0000000000..3791b544f7 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-not-final-obj.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-obj.case +// - src/dstr-binding/default/for-await-of-async-gen-const-async.template +/*--- +description: Rest element (object binding pattern) may not be followed by any element (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +negative: + phase: early + type: SyntaxError +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[1, 2, 3]]; +})(); + +async function *fn() { + for await (const [...{ x }, y] of asyncIter) { + + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-obj-id.js b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-obj-id.js new file mode 100644 index 0000000000..993b15abb8 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-obj-id.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-id.case +// - src/dstr-binding/default/for-await-of-async-gen-const-async.template +/*--- +description: Rest element containing an object binding pattern (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[1, 2, 3]]; +})(); + +async function *fn() { + for await (const [...{ length }] of asyncIter) { + assert.sameValue(length, 3); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-obj-prop-id.js b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-obj-prop-id.js new file mode 100644 index 0000000000..028a44af38 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-obj-prop-id.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-prop-id.case +// - src/dstr-binding/default/for-await-of-async-gen-const-async.template +/*--- +description: Rest element containing an object binding pattern (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +let length = "outer"; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[7, 8, 9]]; +})(); + +async function *fn() { + for await (const [...{ 0: v, 1: w, 2: x, 3: y, length: z }] of asyncIter) { + assert.sameValue(v, 7); + assert.sameValue(w, 8); + assert.sameValue(x, 9); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + assert.sameValue(length, "outer", "the length prop is not set as a binding name"); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-empty.js b/test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-empty.js new file mode 100644 index 0000000000..08320a99e5 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-empty.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-empty.case +// - src/dstr-binding/default/for-await-of-async-gen-const-async.template +/*--- +description: No property access occurs for an "empty" object binding pattern (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ +var accessCount = 0; +var obj = Object.defineProperty({}, 'attr', { + get: function() { + accessCount += 1; + } +}); + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [obj]; +})(); + +async function *fn() { + for await (const {} of asyncIter) { + assert.sameValue(accessCount, 0); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-id-init-fn-name-arrow.js b/test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..e1598d40e8 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-id-init-fn-name-arrow.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-arrow.case +// - src/dstr-binding/default/for-await-of-async-gen-const-async.template +/*--- +description: SingleNameBinding assigns `name` to arrow functions (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{}]; +})(); + +async function *fn() { + for await (const { arrow = () => {} } of asyncIter) { + assert.sameValue(arrow.name, 'arrow'); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-id-init-fn-name-class.js b/test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-id-init-fn-name-class.js new file mode 100644 index 0000000000..137bd77343 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-id-init-fn-name-class.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-class.case +// - src/dstr-binding/default/for-await-of-async-gen-const-async.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{}]; +})(); + +async function *fn() { + for await (const { cls = class {}, xCls = class X {}, xCls2 = class { static name() {} } } of asyncIter) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + assert.notSameValue(xCls2.name, 'xCls2'); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-id-init-fn-name-cover.js b/test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-id-init-fn-name-cover.js new file mode 100644 index 0000000000..484d3f4fe2 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-id-init-fn-name-cover.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-cover.case +// - src/dstr-binding/default/for-await-of-async-gen-const-async.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{}]; +})(); + +async function *fn() { + for await (const { cover = (function () {}), xCover = (0, function() {}) } of asyncIter) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-id-init-fn-name-fn.js b/test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-id-init-fn-name-fn.js new file mode 100644 index 0000000000..ce632b77e9 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-id-init-fn-name-fn.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-fn.case +// - src/dstr-binding/default/for-await-of-async-gen-const-async.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{}]; +})(); + +async function *fn() { + for await (const { fn = function () {}, xFn = function x() {} } of asyncIter) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-id-init-fn-name-gen.js b/test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-id-init-fn-name-gen.js new file mode 100644 index 0000000000..575b7a0dfb --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-id-init-fn-name-gen.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-gen.case +// - src/dstr-binding/default/for-await-of-async-gen-const-async.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{}]; +})(); + +async function *fn() { + for await (const { gen = function* () {}, xGen = function* x() {} } of asyncIter) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-id-init-skipped.js b/test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-id-init-skipped.js new file mode 100644 index 0000000000..3497ef78c9 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-id-init-skipped.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-skipped.case +// - src/dstr-binding/default/for-await-of-async-gen-const-async.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{ w: null, x: 0, y: false, z: '' }]; +})(); + +async function *fn() { + for await (const { w = counter(), x = counter(), y = counter(), z = counter() } of asyncIter) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-id-trailing-comma.js b/test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-id-trailing-comma.js new file mode 100644 index 0000000000..5ace88ecf7 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-id-trailing-comma.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-trailing-comma.case +// - src/dstr-binding/default/for-await-of-async-gen-const-async.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{ x: 23 }]; +})(); + +async function *fn() { + for await (const { x, } of asyncIter) { + assert.sameValue(x, 23); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-prop-ary-init.js b/test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-prop-ary-init.js new file mode 100644 index 0000000000..d6c5976d5e --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-prop-ary-init.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-init.case +// - src/dstr-binding/default/for-await-of-async-gen-const-async.template +/*--- +description: Object binding pattern with "nested" array binding pattern using initializer (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{}]; +})(); + +async function *fn() { + for await (const { w: [x, y, z] = [4, 5, 6] } of asyncIter) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-prop-ary-trailing-comma.js b/test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-prop-ary-trailing-comma.js new file mode 100644 index 0000000000..1f3e852fbc --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-prop-ary-trailing-comma.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-trailing-comma.case +// - src/dstr-binding/default/for-await-of-async-gen-const-async.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{ x: [45] }]; +})(); + +async function *fn() { + for await (const { x: [y], } of asyncIter) { + assert.sameValue(y,45); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-prop-ary.js b/test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-prop-ary.js new file mode 100644 index 0000000000..898d446146 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-prop-ary.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary.case +// - src/dstr-binding/default/for-await-of-async-gen-const-async.template +/*--- +description: Object binding pattern with "nested" array binding pattern not using initializer (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{ w: [7, undefined, ] }]; +})(); + +async function *fn() { + for await (const { w: [x, y, z] = [4, 5, 6] } of asyncIter) { + assert.sameValue(x, 7); + assert.sameValue(y, undefined); + assert.sameValue(z, undefined); + + assert.throws(ReferenceError, function() { + w; + }); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-prop-id-init-skipped.js b/test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-prop-id-init-skipped.js new file mode 100644 index 0000000000..009100990b --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-prop-id-init-skipped.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case +// - src/dstr-binding/default/for-await-of-async-gen-const-async.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{ s: null, u: 0, w: false, y: '' }]; +})(); + +async function *fn() { + for await (const { s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() } of asyncIter) { + assert.sameValue(t, null); + assert.sameValue(v, 0); + assert.sameValue(x, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + assert.throws(ReferenceError, function() { + s; + }); + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-prop-id-init.js b/test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-prop-id-init.js new file mode 100644 index 0000000000..2d65396991 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-prop-id-init.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init.case +// - src/dstr-binding/default/for-await-of-async-gen-const-async.template +/*--- +description: Binding as specified via property name, identifier, and initializer (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{ }]; +})(); + +async function *fn() { + for await (const { x: y = 33 } of asyncIter) { + assert.sameValue(y, 33); + assert.throws(ReferenceError, function() { + x; + }); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-prop-id-trailing-comma.js b/test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-prop-id-trailing-comma.js new file mode 100644 index 0000000000..a6fcec9926 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-prop-id-trailing-comma.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-trailing-comma.case +// - src/dstr-binding/default/for-await-of-async-gen-const-async.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{ x: 23 }]; +})(); + +async function *fn() { + for await (const { x: y, } of asyncIter) { + assert.sameValue(y, 23); + + assert.throws(ReferenceError, function() { + x; + }); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-prop-id.js b/test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-prop-id.js new file mode 100644 index 0000000000..99e56ea379 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-prop-id.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id.case +// - src/dstr-binding/default/for-await-of-async-gen-const-async.template +/*--- +description: Binding as specified via property name and identifier (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{ x: 23 }]; +})(); + +async function *fn() { + for await (const { x: y } of asyncIter) { + assert.sameValue(y, 23); + assert.throws(ReferenceError, function() { + x; + }); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-prop-obj-init.js b/test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-prop-obj-init.js new file mode 100644 index 0000000000..095118c761 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-prop-obj-init.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-init.case +// - src/dstr-binding/default/for-await-of-async-gen-const-async.template +/*--- +description: Object binding pattern with "nested" object binding pattern using initializer (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{ w: undefined }]; +})(); + +async function *fn() { + for await (const { w: { x, y, z } = { x: 4, y: 5, z: 6 } } of asyncIter) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-prop-obj.js b/test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-prop-obj.js new file mode 100644 index 0000000000..404cff1d40 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-prop-obj.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj.case +// - src/dstr-binding/default/for-await-of-async-gen-const-async.template +/*--- +description: Object binding pattern with "nested" object binding pattern not using initializer (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{ w: { x: undefined, z: 7 } }]; +})(); + +async function *fn() { + for await (const { w: { x, y, z } = { x: 4, y: 5, z: 6 } } of asyncIter) { + assert.sameValue(x, undefined); + assert.sameValue(y, undefined); + assert.sameValue(z, 7); + + assert.throws(ReferenceError, function() { + w; + }); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-rest-getter.js b/test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-rest-getter.js new file mode 100644 index 0000000000..f7a85a7590 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-rest-getter.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-getter.case +// - src/dstr-binding/default/for-await-of-async-gen-const-async.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [object-rest, destructuring-binding, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] +---*/ +var count = 0; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{ get v() { count++; return 2; } }]; +})(); + +async function *fn() { + for await (const {...x} of asyncIter) { + assert.sameValue(x.v, 2); + assert.sameValue(count, 1); + + verifyEnumerable(x, "v"); + verifyWritable(x, "v"); + verifyConfigurable(x, "v"); + + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-rest-nested-obj.js b/test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-rest-nested-obj.js new file mode 100644 index 0000000000..e490e3d192 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-rest-nested-obj.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-nested-obj.case +// - src/dstr-binding/default/for-await-of-async-gen-const-async.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment. (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [object-rest, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] +---*/ +var obj = {a: 3, b: 4}; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{a: 1, b: 2, c: 3, d: 4, e: 5}]; +})(); + +async function *fn() { + for await (const {a, b, ...{c, e}} of asyncIter) { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + assert.sameValue(e, 5); + + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-rest-obj-nested-rest.js b/test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-rest-obj-nested-rest.js new file mode 100644 index 0000000000..78bbe16d3e --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-rest-obj-nested-rest.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-nested-rest.case +// - src/dstr-binding/default/for-await-of-async-gen-const-async.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment and object rest desconstruction is allowed in that case. (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [object-rest, destructuring-binding, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{a: 1, b: 2, c: 3, d: 4, e: 5}]; +})(); + +async function *fn() { + for await (const {a, b, ...{c, ...rest}} of asyncIter) { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + + assert.sameValue(rest.d, 4); + assert.sameValue(rest.e, 5); + + verifyEnumerable(rest, "d"); + verifyWritable(rest, "d"); + verifyConfigurable(rest, "d"); + + verifyEnumerable(rest, "e"); + verifyWritable(rest, "e"); + verifyConfigurable(rest, "e"); + + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-rest-obj-own-property.js b/test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-rest-obj-own-property.js new file mode 100644 index 0000000000..c5089cda6e --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-rest-obj-own-property.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-own-property.case +// - src/dstr-binding/default/for-await-of-async-gen-const-async.template +/*--- +description: Rest object contains just soruce object's own properties (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [object-rest, destructuring-binding, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] +---*/ +var o = Object.create({ x: 1, y: 2 }); +o.z = 3; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [o]; +})(); + +async function *fn() { + for await (const { x, ...{y , z} } of asyncIter) { + assert.sameValue(x, 1); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-rest-skip-non-enumerable.js b/test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..074bc0f0c3 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-rest-skip-non-enumerable.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-skip-non-enumerable.case +// - src/dstr-binding/default/for-await-of-async-gen-const-async.template +/*--- +description: Rest object doesn't contain non-enumerable properties (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [object-rest, destructuring-binding, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] +---*/ +var o = {a: 3, b: 4}; +Object.defineProperty(o, "x", { value: 4, enumerable: false }); + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [o]; +})(); + +async function *fn() { + for await (const {...rest} of asyncIter) { + assert.sameValue(rest.a, 3); + assert.sameValue(rest.b, 4); + assert.sameValue(rest.x, undefined); + + verifyEnumerable(rest, "a"); + verifyWritable(rest, "a"); + verifyConfigurable(rest, "a"); + + verifyEnumerable(rest, "b"); + verifyWritable(rest, "b"); + verifyConfigurable(rest, "b"); + + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-rest-val-obj.js b/test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-rest-val-obj.js new file mode 100644 index 0000000000..09a31e9c45 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-rest-val-obj.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-val-obj.case +// - src/dstr-binding/default/for-await-of-async-gen-const-async.template +/*--- +description: Rest object contains just unextracted data (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [object-rest, destructuring-binding, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{x: 1, y: 2, a: 5, b: 3}]; +})(); + +async function *fn() { + for await (const {a, b, ...rest} of asyncIter) { + assert.sameValue(rest.x, 1); + assert.sameValue(rest.y, 2); + assert.sameValue(rest.a, undefined); + assert.sameValue(rest.b, undefined); + + verifyEnumerable(rest, "x"); + verifyWritable(rest, "x"); + verifyConfigurable(rest, "x"); + + verifyEnumerable(rest, "y"); + verifyWritable(rest, "y"); + verifyConfigurable(rest, "y"); + + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-init-iter-close.js b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-init-iter-close.js new file mode 100644 index 0000000000..105b085dc1 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-init-iter-close.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-close.case +// - src/dstr-binding/default/for-await-of-async-gen-let-async.template +/*--- +description: Iterator is closed when not exhausted by pattern evaluation (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [Symbol.iterator, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: false }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [iter]; +})(); + +async function *fn() { + for await (let [x] of asyncIter) { + assert.sameValue(doneCallCount, 1); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-init-iter-no-close.js b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-init-iter-no-close.js new file mode 100644 index 0000000000..ef51abc67d --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-init-iter-no-close.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-no-close.case +// - src/dstr-binding/default/for-await-of-async-gen-let-async.template +/*--- +description: Iterator is not closed when exhausted by pattern evaluation (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [Symbol.iterator, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: true }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [iter]; +})(); + +async function *fn() { + for await (let [x] of asyncIter) { + assert.sameValue(doneCallCount, 0); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-name-iter-val.js b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-name-iter-val.js new file mode 100644 index 0000000000..588330ddb6 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-name-iter-val.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-name-iter-val.case +// - src/dstr-binding/default/for-await-of-async-gen-let-async.template +/*--- +description: SingleNameBinding with normal value iteration (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[1, 2, 3]]; +})(); + +async function *fn() { + for await (let [x, y, z] of asyncIter) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-ary-elem-init.js b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-ary-elem-init.js new file mode 100644 index 0000000000..01d9eb38e1 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-ary-elem-init.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-init.case +// - src/dstr-binding/default/for-await-of-async-gen-let-async.template +/*--- +description: BindingElement with array binding pattern and initializer is used (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function *fn() { + for await (let [[x, y, z] = [4, 5, 6]] of asyncIter) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-ary-elem-iter.js b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-ary-elem-iter.js new file mode 100644 index 0000000000..3cd0e902b0 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-ary-elem-iter.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-iter.case +// - src/dstr-binding/default/for-await-of-async-gen-let-async.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[[7, 8, 9]]]; +})(); + +async function *fn() { + for await (let [[x, y, z] = [4, 5, 6]] of asyncIter) { + assert.sameValue(x, 7); + assert.sameValue(y, 8); + assert.sameValue(z, 9); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-ary-elision-init.js b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-ary-elision-init.js new file mode 100644 index 0000000000..afe206ba12 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-ary-elision-init.js @@ -0,0 +1,75 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case +// - src/dstr-binding/default/for-await-of-async-gen-let-async.template +/*--- +description: BindingElement with array binding pattern and initializer is used (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [generators, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function *fn() { + for await (let [[,] = g()] of asyncIter) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-ary-elision-iter.js b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-ary-elision-iter.js new file mode 100644 index 0000000000..647aa4cd04 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-ary-elision-iter.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-iter.case +// - src/dstr-binding/default/for-await-of-async-gen-let-async.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [generators, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var callCount = 0; +function* g() { + callCount += 1; +}; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[[]]]; +})(); + +async function *fn() { + for await (let [[,] = g()] of asyncIter) { + assert.sameValue(callCount, 0); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-ary-empty-init.js b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-ary-empty-init.js new file mode 100644 index 0000000000..d83c4312ac --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-ary-empty-init.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-init.case +// - src/dstr-binding/default/for-await-of-async-gen-let-async.template +/*--- +description: BindingElement with array binding pattern and initializer is used (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; +var iterCount = 0; +var iter = function*() { iterCount += 1; }(); + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function *fn() { + for await (let [[] = function() { initCount += 1; return iter; }()] of asyncIter) { + assert.sameValue(initCount, 1); + assert.sameValue(iterCount, 0); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-ary-empty-iter.js b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-ary-empty-iter.js new file mode 100644 index 0000000000..74d126e4f7 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-ary-empty-iter.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-iter.case +// - src/dstr-binding/default/for-await-of-async-gen-let-async.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[[23]]]; +})(); + +async function *fn() { + for await (let [[] = function() { initCount += 1; }()] of asyncIter) { + assert.sameValue(initCount, 0); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-ary-rest-init.js b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-ary-rest-init.js new file mode 100644 index 0000000000..7cbf95219c --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-ary-rest-init.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-init.case +// - src/dstr-binding/default/for-await-of-async-gen-let-async.template +/*--- +description: BindingElement with array binding pattern and initializer is used (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function *fn() { + for await (let [[...x] = values] of asyncIter) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-ary-rest-iter.js b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-ary-rest-iter.js new file mode 100644 index 0000000000..790e24cc71 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-ary-rest-iter.js @@ -0,0 +1,75 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-iter.case +// - src/dstr-binding/default/for-await-of-async-gen-let-async.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; +var initCount = 0; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[values]]; +})(); + +async function *fn() { + for await (let [[...x] = function() { initCount += 1; }()] of asyncIter) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + assert.sameValue(initCount, 0); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-init-exhausted.js b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-init-exhausted.js new file mode 100644 index 0000000000..c3842c1cdf --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-init-exhausted.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-exhausted.case +// - src/dstr-binding/default/for-await-of-async-gen-let-async.template +/*--- +description: Destructuring initializer with an exhausted iterator (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function *fn() { + for await (let [x = 23] of asyncIter) { + assert.sameValue(x, 23); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-init-fn-name-arrow.js b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..3ab8334626 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-init-fn-name-arrow.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-arrow.case +// - src/dstr-binding/default/for-await-of-async-gen-let-async.template +/*--- +description: SingleNameBinding does assign name to arrow functions (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function *fn() { + for await (let [arrow = () => {}] of asyncIter) { + assert.sameValue(arrow.name, 'arrow'); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-init-fn-name-class.js b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-init-fn-name-class.js new file mode 100644 index 0000000000..e24437e7a3 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-init-fn-name-class.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-class.case +// - src/dstr-binding/default/for-await-of-async-gen-let-async.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function *fn() { + for await (let [cls = class {}, xCls = class X {}, xCls2 = class { static name() {} }] of asyncIter) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + assert.notSameValue(xCls2.name, 'xCls2'); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-init-fn-name-cover.js b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-init-fn-name-cover.js new file mode 100644 index 0000000000..a78c9d193d --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-init-fn-name-cover.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-cover.case +// - src/dstr-binding/default/for-await-of-async-gen-let-async.template +/*--- +description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function *fn() { + for await (let [cover = (function () {}), xCover = (0, function() {})] of asyncIter) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-init-fn-name-fn.js b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-init-fn-name-fn.js new file mode 100644 index 0000000000..0603be91c0 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-init-fn-name-fn.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-fn.case +// - src/dstr-binding/default/for-await-of-async-gen-let-async.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function *fn() { + for await (let [fn = function () {}, xFn = function x() {}] of asyncIter) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-init-fn-name-gen.js b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-init-fn-name-gen.js new file mode 100644 index 0000000000..f9e825dc52 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-init-fn-name-gen.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-gen.case +// - src/dstr-binding/default/for-await-of-async-gen-let-async.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function *fn() { + for await (let [gen = function* () {}, xGen = function* x() {}] of asyncIter) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-init-hole.js b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-init-hole.js new file mode 100644 index 0000000000..a9d94cb0b2 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-init-hole.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-hole.case +// - src/dstr-binding/default/for-await-of-async-gen-let-async.template +/*--- +description: Destructuring initializer with a "hole" (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + SingleNameBinding : BindingIdentifier Initializeropt + [...] 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[,]]; +})(); + +async function *fn() { + for await (let [x = 23] of asyncIter) { + assert.sameValue(x, 23); + // another statement + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-init-skipped.js b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-init-skipped.js new file mode 100644 index 0000000000..2c2093fa51 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-init-skipped.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-skipped.case +// - src/dstr-binding/default/for-await-of-async-gen-let-async.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[null, 0, false, '']]; +})(); + +async function *fn() { + for await (let [w = counter(), x = counter(), y = counter(), z = counter()] of asyncIter) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-init-undef.js b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-init-undef.js new file mode 100644 index 0000000000..3b9a6f3410 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-init-undef.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-undef.case +// - src/dstr-binding/default/for-await-of-async-gen-let-async.template +/*--- +description: Destructuring initializer with an undefined value (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[undefined]]; +})(); + +async function *fn() { + for await (let [x = 23] of asyncIter) { + assert.sameValue(x, 23); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-iter-complete.js b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-iter-complete.js new file mode 100644 index 0000000000..122e1c1672 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-iter-complete.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-complete.case +// - src/dstr-binding/default/for-await-of-async-gen-let-async.template +/*--- +description: SingleNameBinding when value iteration completes (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function *fn() { + for await (let [x] of asyncIter) { + assert.sameValue(x, undefined); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-iter-done.js b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-iter-done.js new file mode 100644 index 0000000000..a9fb3f0abb --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-iter-done.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-done.case +// - src/dstr-binding/default/for-await-of-async-gen-let-async.template +/*--- +description: SingleNameBinding when value iteration was completed previously (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function *fn() { + for await (let [_, x] of asyncIter) { + assert.sameValue(x, undefined); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-iter-val.js b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-iter-val.js new file mode 100644 index 0000000000..d31c94dcb2 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-iter-val.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val.case +// - src/dstr-binding/default/for-await-of-async-gen-let-async.template +/*--- +description: SingleNameBinding when value iteration was completed previously (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[1, 2, 3]]; +})(); + +async function *fn() { + for await (let [x, y, z] of asyncIter) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-obj-id-init.js b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-obj-id-init.js new file mode 100644 index 0000000000..06f12fa124 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-obj-id-init.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id-init.case +// - src/dstr-binding/default/for-await-of-async-gen-let-async.template +/*--- +description: BindingElement with object binding pattern and initializer is used (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function *fn() { + for await (let [{ x, y, z } = { x: 44, y: 55, z: 66 }] of asyncIter) { + assert.sameValue(x, 44); + assert.sameValue(y, 55); + assert.sameValue(z, 66); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-obj-id.js b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-obj-id.js new file mode 100644 index 0000000000..557a31fd68 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-obj-id.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id.case +// - src/dstr-binding/default/for-await-of-async-gen-let-async.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[{ x: 11, y: 22, z: 33 }]]; +})(); + +async function *fn() { + for await (let [{ x, y, z } = { x: 44, y: 55, z: 66 }] of asyncIter) { + assert.sameValue(x, 11); + assert.sameValue(y, 22); + assert.sameValue(z, 33); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-obj-prop-id-init.js b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-obj-prop-id-init.js new file mode 100644 index 0000000000..e984783260 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-obj-prop-id-init.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id-init.case +// - src/dstr-binding/default/for-await-of-async-gen-let-async.template +/*--- +description: BindingElement with object binding pattern and initializer is used (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function *fn() { + for await (let [{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] of asyncIter) { + assert.sameValue(v, 444); + assert.sameValue(x, 555); + assert.sameValue(z, 666); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-obj-prop-id.js b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-obj-prop-id.js new file mode 100644 index 0000000000..71506bbe6a --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-obj-prop-id.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id.case +// - src/dstr-binding/default/for-await-of-async-gen-let-async.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[{ u: 777, w: 888, y: 999 }]]; +})(); + +async function *fn() { + for await (let [{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] of asyncIter) { + assert.sameValue(v, 777); + assert.sameValue(x, 888); + assert.sameValue(z, 999); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elision-exhausted.js b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elision-exhausted.js new file mode 100644 index 0000000000..7edd76f6e5 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elision-exhausted.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-exhausted.case +// - src/dstr-binding/default/for-await-of-async-gen-let-async.template +/*--- +description: Elision accepts exhausted iterator (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [generator, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + [...] + 2. Return NormalCompletion(empty). + +---*/ +var iter = function*() {}(); +iter.next(); + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [iter]; +})(); + +async function *fn() { + for await (let [,] of asyncIter) { + + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elision.js b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elision.js new file mode 100644 index 0000000000..2871051b4f --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elision.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision.case +// - src/dstr-binding/default/for-await-of-async-gen-let-async.template +/*--- +description: Elision advances iterator (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [generator, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [g()]; +})(); + +async function *fn() { + for await (let [,] of asyncIter) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-empty.js b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-empty.js new file mode 100644 index 0000000000..9de73e04e5 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-empty.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-empty.case +// - src/dstr-binding/default/for-await-of-async-gen-let-async.template +/*--- +description: No iteration occurs for an "empty" array binding pattern (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [generators, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [iter]; +})(); + +async function *fn() { + for await (let [] of asyncIter) { + assert.sameValue(iterations, 0); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-ary-elem.js b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-ary-elem.js new file mode 100644 index 0000000000..ccb2c1f1a5 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-ary-elem.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elem.case +// - src/dstr-binding/default/for-await-of-async-gen-let-async.template +/*--- +description: Rest element containing an array BindingElementList pattern (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[3, 4, 5]]; +})(); + +async function *fn() { + for await (let [...[x, y, z]] of asyncIter) { + assert.sameValue(x, 3); + assert.sameValue(y, 4); + assert.sameValue(z, 5); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-ary-elision.js b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-ary-elision.js new file mode 100644 index 0000000000..df112ef2cb --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-ary-elision.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elision.case +// - src/dstr-binding/default/for-await-of-async-gen-let-async.template +/*--- +description: Rest element containing an elision (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [generators, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [g()]; +})(); + +async function *fn() { + for await (let [...[,]] of asyncIter) { + assert.sameValue(first, 1); + assert.sameValue(second, 1); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-ary-empty.js b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-ary-empty.js new file mode 100644 index 0000000000..f39b0cdc0c --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-ary-empty.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-empty.case +// - src/dstr-binding/default/for-await-of-async-gen-let-async.template +/*--- +description: Rest element containing an "empty" array pattern (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [generators, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [iter]; +})(); + +async function *fn() { + for await (let [...[]] of asyncIter) { + assert.sameValue(iterations, 1); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-ary-rest.js b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-ary-rest.js new file mode 100644 index 0000000000..f5e808c784 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-ary-rest.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-rest.case +// - src/dstr-binding/default/for-await-of-async-gen-let-async.template +/*--- +description: Rest element containing a rest element (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +var values = [1, 2, 3]; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [values]; +})(); + +async function *fn() { + for await (let [...[...x]] of asyncIter) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-id-elision.js b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-id-elision.js new file mode 100644 index 0000000000..491081feec --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-id-elision.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision.case +// - src/dstr-binding/default/for-await-of-async-gen-let-async.template +/*--- +description: Rest element following elision elements (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. +---*/ +var values = [1, 2, 3, 4, 5]; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [values]; +})(); + +async function *fn() { + for await (let [ , , ...x] of asyncIter) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 3); + assert.sameValue(x[1], 4); + assert.sameValue(x[2], 5); + assert.notSameValue(x, values); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-id-exhausted.js b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-id-exhausted.js new file mode 100644 index 0000000000..b267cda1d0 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-id-exhausted.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-exhausted.case +// - src/dstr-binding/default/for-await-of-async-gen-let-async.template +/*--- +description: RestElement applied to an exhausted iterator (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [Symbol.iterator, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + b. If iteratorRecord.[[done]] is true, then + i. If environment is undefined, return PutValue(lhs, A). + ii. Return InitializeReferencedBinding(lhs, A). + +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[1, 2]]; +})(); + +async function *fn() { + for await (let [, , ...x] of asyncIter) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 0); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-id.js b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-id.js new file mode 100644 index 0000000000..07fe2e0361 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-id.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id.case +// - src/dstr-binding/default/for-await-of-async-gen-let-async.template +/*--- +description: Lone rest element (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat + [...] + f. Let status be CreateDataProperty(A, ToString (n), nextValue). + [...] +---*/ +var values = [1, 2, 3]; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [values]; +})(); + +async function *fn() { + for await (let [...x] of asyncIter) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-init-ary.js b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-init-ary.js new file mode 100644 index 0000000000..63237664fc --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-init-ary.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-ary.case +// - src/dstr-binding/default/for-await-of-async-gen-let-async.template +/*--- +description: Reset element (nested array pattern) does not support initializer (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +negative: + phase: early + type: SyntaxError +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function *fn() { + for await (let [...[ x ] = []] of asyncIter) { + + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-init-id.js b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-init-id.js new file mode 100644 index 0000000000..ebdba4e66e --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-init-id.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-id.case +// - src/dstr-binding/default/for-await-of-async-gen-let-async.template +/*--- +description: Reset element (identifier) does not support initializer (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +negative: + phase: early + type: SyntaxError +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function *fn() { + for await (let [...x = []] of asyncIter) { + + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-init-obj.js b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-init-obj.js new file mode 100644 index 0000000000..df2ea0c015 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-init-obj.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-obj.case +// - src/dstr-binding/default/for-await-of-async-gen-let-async.template +/*--- +description: Reset element (nested object pattern) does not support initializer (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +negative: + phase: early + type: SyntaxError +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function *fn() { + for await (let [...{ x } = []] of asyncIter) { + + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-not-final-ary.js b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-not-final-ary.js new file mode 100644 index 0000000000..b06ced0e10 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-not-final-ary.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-ary.case +// - src/dstr-binding/default/for-await-of-async-gen-let-async.template +/*--- +description: Rest element (array binding pattern) may not be followed by any element (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +negative: + phase: early + type: SyntaxError +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[1, 2, 3]]; +})(); + +async function *fn() { + for await (let [...[x], y] of asyncIter) { + + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-not-final-id.js b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-not-final-id.js new file mode 100644 index 0000000000..46d33ca952 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-not-final-id.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-id.case +// - src/dstr-binding/default/for-await-of-async-gen-let-async.template +/*--- +description: Rest element (identifier) may not be followed by any element (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +negative: + phase: early + type: SyntaxError +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[1, 2, 3]]; +})(); + +async function *fn() { + for await (let [...x, y] of asyncIter) { + + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-not-final-obj.js b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-not-final-obj.js new file mode 100644 index 0000000000..6e1ac77707 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-not-final-obj.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-obj.case +// - src/dstr-binding/default/for-await-of-async-gen-let-async.template +/*--- +description: Rest element (object binding pattern) may not be followed by any element (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +negative: + phase: early + type: SyntaxError +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[1, 2, 3]]; +})(); + +async function *fn() { + for await (let [...{ x }, y] of asyncIter) { + + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-obj-id.js b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-obj-id.js new file mode 100644 index 0000000000..ec4d6b3723 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-obj-id.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-id.case +// - src/dstr-binding/default/for-await-of-async-gen-let-async.template +/*--- +description: Rest element containing an object binding pattern (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[1, 2, 3]]; +})(); + +async function *fn() { + for await (let [...{ length }] of asyncIter) { + assert.sameValue(length, 3); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-obj-prop-id.js b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-obj-prop-id.js new file mode 100644 index 0000000000..f465a8f8d4 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-obj-prop-id.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-prop-id.case +// - src/dstr-binding/default/for-await-of-async-gen-let-async.template +/*--- +description: Rest element containing an object binding pattern (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +let length = "outer"; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[7, 8, 9]]; +})(); + +async function *fn() { + for await (let [...{ 0: v, 1: w, 2: x, 3: y, length: z }] of asyncIter) { + assert.sameValue(v, 7); + assert.sameValue(w, 8); + assert.sameValue(x, 9); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + assert.sameValue(length, "outer", "the length prop is not set as a binding name"); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-empty.js b/test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-empty.js new file mode 100644 index 0000000000..5c04bbf9d5 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-empty.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-empty.case +// - src/dstr-binding/default/for-await-of-async-gen-let-async.template +/*--- +description: No property access occurs for an "empty" object binding pattern (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ +var accessCount = 0; +var obj = Object.defineProperty({}, 'attr', { + get: function() { + accessCount += 1; + } +}); + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [obj]; +})(); + +async function *fn() { + for await (let {} of asyncIter) { + assert.sameValue(accessCount, 0); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-id-init-fn-name-arrow.js b/test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..8e95c3d7a1 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-id-init-fn-name-arrow.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-arrow.case +// - src/dstr-binding/default/for-await-of-async-gen-let-async.template +/*--- +description: SingleNameBinding assigns `name` to arrow functions (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{}]; +})(); + +async function *fn() { + for await (let { arrow = () => {} } of asyncIter) { + assert.sameValue(arrow.name, 'arrow'); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-id-init-fn-name-class.js b/test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-id-init-fn-name-class.js new file mode 100644 index 0000000000..d74ecb6984 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-id-init-fn-name-class.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-class.case +// - src/dstr-binding/default/for-await-of-async-gen-let-async.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{}]; +})(); + +async function *fn() { + for await (let { cls = class {}, xCls = class X {}, xCls2 = class { static name() {} } } of asyncIter) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + assert.notSameValue(xCls2.name, 'xCls2'); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-id-init-fn-name-cover.js b/test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-id-init-fn-name-cover.js new file mode 100644 index 0000000000..bfd6096848 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-id-init-fn-name-cover.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-cover.case +// - src/dstr-binding/default/for-await-of-async-gen-let-async.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{}]; +})(); + +async function *fn() { + for await (let { cover = (function () {}), xCover = (0, function() {}) } of asyncIter) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-id-init-fn-name-fn.js b/test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-id-init-fn-name-fn.js new file mode 100644 index 0000000000..e613678b4d --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-id-init-fn-name-fn.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-fn.case +// - src/dstr-binding/default/for-await-of-async-gen-let-async.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{}]; +})(); + +async function *fn() { + for await (let { fn = function () {}, xFn = function x() {} } of asyncIter) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-id-init-fn-name-gen.js b/test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-id-init-fn-name-gen.js new file mode 100644 index 0000000000..f6d474be34 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-id-init-fn-name-gen.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-gen.case +// - src/dstr-binding/default/for-await-of-async-gen-let-async.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{}]; +})(); + +async function *fn() { + for await (let { gen = function* () {}, xGen = function* x() {} } of asyncIter) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-id-init-skipped.js b/test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-id-init-skipped.js new file mode 100644 index 0000000000..aebc133d72 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-id-init-skipped.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-skipped.case +// - src/dstr-binding/default/for-await-of-async-gen-let-async.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{ w: null, x: 0, y: false, z: '' }]; +})(); + +async function *fn() { + for await (let { w = counter(), x = counter(), y = counter(), z = counter() } of asyncIter) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-id-trailing-comma.js b/test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-id-trailing-comma.js new file mode 100644 index 0000000000..e2554571c9 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-id-trailing-comma.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-trailing-comma.case +// - src/dstr-binding/default/for-await-of-async-gen-let-async.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{ x: 23 }]; +})(); + +async function *fn() { + for await (let { x, } of asyncIter) { + assert.sameValue(x, 23); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-prop-ary-init.js b/test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-prop-ary-init.js new file mode 100644 index 0000000000..8645bf1bdb --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-prop-ary-init.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-init.case +// - src/dstr-binding/default/for-await-of-async-gen-let-async.template +/*--- +description: Object binding pattern with "nested" array binding pattern using initializer (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{}]; +})(); + +async function *fn() { + for await (let { w: [x, y, z] = [4, 5, 6] } of asyncIter) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-prop-ary-trailing-comma.js b/test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-prop-ary-trailing-comma.js new file mode 100644 index 0000000000..2b771ad15f --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-prop-ary-trailing-comma.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-trailing-comma.case +// - src/dstr-binding/default/for-await-of-async-gen-let-async.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{ x: [45] }]; +})(); + +async function *fn() { + for await (let { x: [y], } of asyncIter) { + assert.sameValue(y,45); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-prop-ary.js b/test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-prop-ary.js new file mode 100644 index 0000000000..048d1135f7 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-prop-ary.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary.case +// - src/dstr-binding/default/for-await-of-async-gen-let-async.template +/*--- +description: Object binding pattern with "nested" array binding pattern not using initializer (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{ w: [7, undefined, ] }]; +})(); + +async function *fn() { + for await (let { w: [x, y, z] = [4, 5, 6] } of asyncIter) { + assert.sameValue(x, 7); + assert.sameValue(y, undefined); + assert.sameValue(z, undefined); + + assert.throws(ReferenceError, function() { + w; + }); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-prop-id-init-skipped.js b/test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-prop-id-init-skipped.js new file mode 100644 index 0000000000..76ffc91b03 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-prop-id-init-skipped.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case +// - src/dstr-binding/default/for-await-of-async-gen-let-async.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{ s: null, u: 0, w: false, y: '' }]; +})(); + +async function *fn() { + for await (let { s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() } of asyncIter) { + assert.sameValue(t, null); + assert.sameValue(v, 0); + assert.sameValue(x, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + assert.throws(ReferenceError, function() { + s; + }); + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-prop-id-init.js b/test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-prop-id-init.js new file mode 100644 index 0000000000..ab25220a3d --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-prop-id-init.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init.case +// - src/dstr-binding/default/for-await-of-async-gen-let-async.template +/*--- +description: Binding as specified via property name, identifier, and initializer (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{ }]; +})(); + +async function *fn() { + for await (let { x: y = 33 } of asyncIter) { + assert.sameValue(y, 33); + assert.throws(ReferenceError, function() { + x; + }); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-prop-id-trailing-comma.js b/test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-prop-id-trailing-comma.js new file mode 100644 index 0000000000..42942794bb --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-prop-id-trailing-comma.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-trailing-comma.case +// - src/dstr-binding/default/for-await-of-async-gen-let-async.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{ x: 23 }]; +})(); + +async function *fn() { + for await (let { x: y, } of asyncIter) { + assert.sameValue(y, 23); + + assert.throws(ReferenceError, function() { + x; + }); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-prop-id.js b/test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-prop-id.js new file mode 100644 index 0000000000..b30295d801 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-prop-id.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id.case +// - src/dstr-binding/default/for-await-of-async-gen-let-async.template +/*--- +description: Binding as specified via property name and identifier (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{ x: 23 }]; +})(); + +async function *fn() { + for await (let { x: y } of asyncIter) { + assert.sameValue(y, 23); + assert.throws(ReferenceError, function() { + x; + }); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-prop-obj-init.js b/test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-prop-obj-init.js new file mode 100644 index 0000000000..66c05e0ce2 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-prop-obj-init.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-init.case +// - src/dstr-binding/default/for-await-of-async-gen-let-async.template +/*--- +description: Object binding pattern with "nested" object binding pattern using initializer (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{ w: undefined }]; +})(); + +async function *fn() { + for await (let { w: { x, y, z } = { x: 4, y: 5, z: 6 } } of asyncIter) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-prop-obj.js b/test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-prop-obj.js new file mode 100644 index 0000000000..431b5aa01a --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-prop-obj.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj.case +// - src/dstr-binding/default/for-await-of-async-gen-let-async.template +/*--- +description: Object binding pattern with "nested" object binding pattern not using initializer (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{ w: { x: undefined, z: 7 } }]; +})(); + +async function *fn() { + for await (let { w: { x, y, z } = { x: 4, y: 5, z: 6 } } of asyncIter) { + assert.sameValue(x, undefined); + assert.sameValue(y, undefined); + assert.sameValue(z, 7); + + assert.throws(ReferenceError, function() { + w; + }); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-rest-getter.js b/test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-rest-getter.js new file mode 100644 index 0000000000..7bc9307bb9 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-rest-getter.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-getter.case +// - src/dstr-binding/default/for-await-of-async-gen-let-async.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [object-rest, destructuring-binding, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] +---*/ +var count = 0; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{ get v() { count++; return 2; } }]; +})(); + +async function *fn() { + for await (let {...x} of asyncIter) { + assert.sameValue(x.v, 2); + assert.sameValue(count, 1); + + verifyEnumerable(x, "v"); + verifyWritable(x, "v"); + verifyConfigurable(x, "v"); + + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-rest-nested-obj.js b/test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-rest-nested-obj.js new file mode 100644 index 0000000000..03f9d10606 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-rest-nested-obj.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-nested-obj.case +// - src/dstr-binding/default/for-await-of-async-gen-let-async.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment. (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [object-rest, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] +---*/ +var obj = {a: 3, b: 4}; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{a: 1, b: 2, c: 3, d: 4, e: 5}]; +})(); + +async function *fn() { + for await (let {a, b, ...{c, e}} of asyncIter) { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + assert.sameValue(e, 5); + + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-rest-obj-nested-rest.js b/test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-rest-obj-nested-rest.js new file mode 100644 index 0000000000..0853db839f --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-rest-obj-nested-rest.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-nested-rest.case +// - src/dstr-binding/default/for-await-of-async-gen-let-async.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment and object rest desconstruction is allowed in that case. (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [object-rest, destructuring-binding, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{a: 1, b: 2, c: 3, d: 4, e: 5}]; +})(); + +async function *fn() { + for await (let {a, b, ...{c, ...rest}} of asyncIter) { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + + assert.sameValue(rest.d, 4); + assert.sameValue(rest.e, 5); + + verifyEnumerable(rest, "d"); + verifyWritable(rest, "d"); + verifyConfigurable(rest, "d"); + + verifyEnumerable(rest, "e"); + verifyWritable(rest, "e"); + verifyConfigurable(rest, "e"); + + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-rest-obj-own-property.js b/test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-rest-obj-own-property.js new file mode 100644 index 0000000000..77e6c82678 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-rest-obj-own-property.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-own-property.case +// - src/dstr-binding/default/for-await-of-async-gen-let-async.template +/*--- +description: Rest object contains just soruce object's own properties (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [object-rest, destructuring-binding, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] +---*/ +var o = Object.create({ x: 1, y: 2 }); +o.z = 3; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [o]; +})(); + +async function *fn() { + for await (let { x, ...{y , z} } of asyncIter) { + assert.sameValue(x, 1); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-rest-skip-non-enumerable.js b/test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..ead8aa0eb3 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-rest-skip-non-enumerable.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-skip-non-enumerable.case +// - src/dstr-binding/default/for-await-of-async-gen-let-async.template +/*--- +description: Rest object doesn't contain non-enumerable properties (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [object-rest, destructuring-binding, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] +---*/ +var o = {a: 3, b: 4}; +Object.defineProperty(o, "x", { value: 4, enumerable: false }); + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [o]; +})(); + +async function *fn() { + for await (let {...rest} of asyncIter) { + assert.sameValue(rest.a, 3); + assert.sameValue(rest.b, 4); + assert.sameValue(rest.x, undefined); + + verifyEnumerable(rest, "a"); + verifyWritable(rest, "a"); + verifyConfigurable(rest, "a"); + + verifyEnumerable(rest, "b"); + verifyWritable(rest, "b"); + verifyConfigurable(rest, "b"); + + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-rest-val-obj.js b/test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-rest-val-obj.js new file mode 100644 index 0000000000..1d941ef790 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-rest-val-obj.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-val-obj.case +// - src/dstr-binding/default/for-await-of-async-gen-let-async.template +/*--- +description: Rest object contains just unextracted data (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [object-rest, destructuring-binding, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{x: 1, y: 2, a: 5, b: 3}]; +})(); + +async function *fn() { + for await (let {a, b, ...rest} of asyncIter) { + assert.sameValue(rest.x, 1); + assert.sameValue(rest.y, 2); + assert.sameValue(rest.a, undefined); + assert.sameValue(rest.b, undefined); + + verifyEnumerable(rest, "x"); + verifyWritable(rest, "x"); + verifyConfigurable(rest, "x"); + + verifyEnumerable(rest, "y"); + verifyWritable(rest, "y"); + verifyConfigurable(rest, "y"); + + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-init-iter-close.js b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-init-iter-close.js new file mode 100644 index 0000000000..03d9db542e --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-init-iter-close.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-close.case +// - src/dstr-binding/default/for-await-of-async-gen-var-async.template +/*--- +description: Iterator is closed when not exhausted by pattern evaluation (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [Symbol.iterator, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: false }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [iter]; +})(); + +async function *fn() { + for await (var [x] of asyncIter) { + assert.sameValue(doneCallCount, 1); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-init-iter-no-close.js b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-init-iter-no-close.js new file mode 100644 index 0000000000..7c0d60c32b --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-init-iter-no-close.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-no-close.case +// - src/dstr-binding/default/for-await-of-async-gen-var-async.template +/*--- +description: Iterator is not closed when exhausted by pattern evaluation (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [Symbol.iterator, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: true }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [iter]; +})(); + +async function *fn() { + for await (var [x] of asyncIter) { + assert.sameValue(doneCallCount, 0); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-name-iter-val.js b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-name-iter-val.js new file mode 100644 index 0000000000..8717837466 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-name-iter-val.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-name-iter-val.case +// - src/dstr-binding/default/for-await-of-async-gen-var-async.template +/*--- +description: SingleNameBinding with normal value iteration (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[1, 2, 3]]; +})(); + +async function *fn() { + for await (var [x, y, z] of asyncIter) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-ary-elem-init.js b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-ary-elem-init.js new file mode 100644 index 0000000000..e8d497685a --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-ary-elem-init.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-init.case +// - src/dstr-binding/default/for-await-of-async-gen-var-async.template +/*--- +description: BindingElement with array binding pattern and initializer is used (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function *fn() { + for await (var [[x, y, z] = [4, 5, 6]] of asyncIter) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-ary-elem-iter.js b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-ary-elem-iter.js new file mode 100644 index 0000000000..9443e4ed27 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-ary-elem-iter.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-iter.case +// - src/dstr-binding/default/for-await-of-async-gen-var-async.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[[7, 8, 9]]]; +})(); + +async function *fn() { + for await (var [[x, y, z] = [4, 5, 6]] of asyncIter) { + assert.sameValue(x, 7); + assert.sameValue(y, 8); + assert.sameValue(z, 9); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-ary-elision-init.js b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-ary-elision-init.js new file mode 100644 index 0000000000..54f8f49ab7 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-ary-elision-init.js @@ -0,0 +1,75 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case +// - src/dstr-binding/default/for-await-of-async-gen-var-async.template +/*--- +description: BindingElement with array binding pattern and initializer is used (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [generators, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function *fn() { + for await (var [[,] = g()] of asyncIter) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-ary-elision-iter.js b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-ary-elision-iter.js new file mode 100644 index 0000000000..100d6d7870 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-ary-elision-iter.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-iter.case +// - src/dstr-binding/default/for-await-of-async-gen-var-async.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [generators, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var callCount = 0; +function* g() { + callCount += 1; +}; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[[]]]; +})(); + +async function *fn() { + for await (var [[,] = g()] of asyncIter) { + assert.sameValue(callCount, 0); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-ary-empty-init.js b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-ary-empty-init.js new file mode 100644 index 0000000000..9f78cf5ce9 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-ary-empty-init.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-init.case +// - src/dstr-binding/default/for-await-of-async-gen-var-async.template +/*--- +description: BindingElement with array binding pattern and initializer is used (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; +var iterCount = 0; +var iter = function*() { iterCount += 1; }(); + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function *fn() { + for await (var [[] = function() { initCount += 1; return iter; }()] of asyncIter) { + assert.sameValue(initCount, 1); + assert.sameValue(iterCount, 0); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-ary-empty-iter.js b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-ary-empty-iter.js new file mode 100644 index 0000000000..64fcc5a287 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-ary-empty-iter.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-iter.case +// - src/dstr-binding/default/for-await-of-async-gen-var-async.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[[23]]]; +})(); + +async function *fn() { + for await (var [[] = function() { initCount += 1; }()] of asyncIter) { + assert.sameValue(initCount, 0); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-ary-rest-init.js b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-ary-rest-init.js new file mode 100644 index 0000000000..70014c0dcb --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-ary-rest-init.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-init.case +// - src/dstr-binding/default/for-await-of-async-gen-var-async.template +/*--- +description: BindingElement with array binding pattern and initializer is used (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function *fn() { + for await (var [[...x] = values] of asyncIter) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-ary-rest-iter.js b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-ary-rest-iter.js new file mode 100644 index 0000000000..9dbb33316e --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-ary-rest-iter.js @@ -0,0 +1,75 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-iter.case +// - src/dstr-binding/default/for-await-of-async-gen-var-async.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; +var initCount = 0; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[values]]; +})(); + +async function *fn() { + for await (var [[...x] = function() { initCount += 1; }()] of asyncIter) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + assert.sameValue(initCount, 0); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-init-exhausted.js b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-init-exhausted.js new file mode 100644 index 0000000000..4227bcf652 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-init-exhausted.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-exhausted.case +// - src/dstr-binding/default/for-await-of-async-gen-var-async.template +/*--- +description: Destructuring initializer with an exhausted iterator (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function *fn() { + for await (var [x = 23] of asyncIter) { + assert.sameValue(x, 23); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-init-fn-name-arrow.js b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..03fa653229 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-init-fn-name-arrow.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-arrow.case +// - src/dstr-binding/default/for-await-of-async-gen-var-async.template +/*--- +description: SingleNameBinding does assign name to arrow functions (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function *fn() { + for await (var [arrow = () => {}] of asyncIter) { + assert.sameValue(arrow.name, 'arrow'); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-init-fn-name-class.js b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-init-fn-name-class.js new file mode 100644 index 0000000000..52b93a0248 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-init-fn-name-class.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-class.case +// - src/dstr-binding/default/for-await-of-async-gen-var-async.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function *fn() { + for await (var [cls = class {}, xCls = class X {}, xCls2 = class { static name() {} }] of asyncIter) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + assert.notSameValue(xCls2.name, 'xCls2'); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-init-fn-name-cover.js b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-init-fn-name-cover.js new file mode 100644 index 0000000000..8d42170b6e --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-init-fn-name-cover.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-cover.case +// - src/dstr-binding/default/for-await-of-async-gen-var-async.template +/*--- +description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function *fn() { + for await (var [cover = (function () {}), xCover = (0, function() {})] of asyncIter) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-init-fn-name-fn.js b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-init-fn-name-fn.js new file mode 100644 index 0000000000..99ce34b7f0 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-init-fn-name-fn.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-fn.case +// - src/dstr-binding/default/for-await-of-async-gen-var-async.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function *fn() { + for await (var [fn = function () {}, xFn = function x() {}] of asyncIter) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-init-fn-name-gen.js b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-init-fn-name-gen.js new file mode 100644 index 0000000000..9fb58367d9 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-init-fn-name-gen.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-gen.case +// - src/dstr-binding/default/for-await-of-async-gen-var-async.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function *fn() { + for await (var [gen = function* () {}, xGen = function* x() {}] of asyncIter) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-init-hole.js b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-init-hole.js new file mode 100644 index 0000000000..49b02c4669 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-init-hole.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-hole.case +// - src/dstr-binding/default/for-await-of-async-gen-var-async.template +/*--- +description: Destructuring initializer with a "hole" (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + SingleNameBinding : BindingIdentifier Initializeropt + [...] 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[,]]; +})(); + +async function *fn() { + for await (var [x = 23] of asyncIter) { + assert.sameValue(x, 23); + // another statement + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-init-skipped.js b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-init-skipped.js new file mode 100644 index 0000000000..9cdaaf662e --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-init-skipped.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-skipped.case +// - src/dstr-binding/default/for-await-of-async-gen-var-async.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[null, 0, false, '']]; +})(); + +async function *fn() { + for await (var [w = counter(), x = counter(), y = counter(), z = counter()] of asyncIter) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-init-undef.js b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-init-undef.js new file mode 100644 index 0000000000..eb3553930d --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-init-undef.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-undef.case +// - src/dstr-binding/default/for-await-of-async-gen-var-async.template +/*--- +description: Destructuring initializer with an undefined value (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[undefined]]; +})(); + +async function *fn() { + for await (var [x = 23] of asyncIter) { + assert.sameValue(x, 23); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-iter-complete.js b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-iter-complete.js new file mode 100644 index 0000000000..870d1683d4 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-iter-complete.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-complete.case +// - src/dstr-binding/default/for-await-of-async-gen-var-async.template +/*--- +description: SingleNameBinding when value iteration completes (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function *fn() { + for await (var [x] of asyncIter) { + assert.sameValue(x, undefined); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-iter-done.js b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-iter-done.js new file mode 100644 index 0000000000..8cf1f20d60 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-iter-done.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-done.case +// - src/dstr-binding/default/for-await-of-async-gen-var-async.template +/*--- +description: SingleNameBinding when value iteration was completed previously (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function *fn() { + for await (var [_, x] of asyncIter) { + assert.sameValue(x, undefined); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-iter-val.js b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-iter-val.js new file mode 100644 index 0000000000..563786d6b5 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-iter-val.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val.case +// - src/dstr-binding/default/for-await-of-async-gen-var-async.template +/*--- +description: SingleNameBinding when value iteration was completed previously (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[1, 2, 3]]; +})(); + +async function *fn() { + for await (var [x, y, z] of asyncIter) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-obj-id-init.js b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-obj-id-init.js new file mode 100644 index 0000000000..5023e2bf27 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-obj-id-init.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id-init.case +// - src/dstr-binding/default/for-await-of-async-gen-var-async.template +/*--- +description: BindingElement with object binding pattern and initializer is used (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function *fn() { + for await (var [{ x, y, z } = { x: 44, y: 55, z: 66 }] of asyncIter) { + assert.sameValue(x, 44); + assert.sameValue(y, 55); + assert.sameValue(z, 66); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-obj-id.js b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-obj-id.js new file mode 100644 index 0000000000..003b341be0 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-obj-id.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id.case +// - src/dstr-binding/default/for-await-of-async-gen-var-async.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[{ x: 11, y: 22, z: 33 }]]; +})(); + +async function *fn() { + for await (var [{ x, y, z } = { x: 44, y: 55, z: 66 }] of asyncIter) { + assert.sameValue(x, 11); + assert.sameValue(y, 22); + assert.sameValue(z, 33); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-obj-prop-id-init.js b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-obj-prop-id-init.js new file mode 100644 index 0000000000..3a0c85c2f8 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-obj-prop-id-init.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id-init.case +// - src/dstr-binding/default/for-await-of-async-gen-var-async.template +/*--- +description: BindingElement with object binding pattern and initializer is used (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function *fn() { + for await (var [{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] of asyncIter) { + assert.sameValue(v, 444); + assert.sameValue(x, 555); + assert.sameValue(z, 666); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-obj-prop-id.js b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-obj-prop-id.js new file mode 100644 index 0000000000..c192aa63c3 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-obj-prop-id.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id.case +// - src/dstr-binding/default/for-await-of-async-gen-var-async.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[{ u: 777, w: 888, y: 999 }]]; +})(); + +async function *fn() { + for await (var [{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] of asyncIter) { + assert.sameValue(v, 777); + assert.sameValue(x, 888); + assert.sameValue(z, 999); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elision-exhausted.js b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elision-exhausted.js new file mode 100644 index 0000000000..16ae92a4b6 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elision-exhausted.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-exhausted.case +// - src/dstr-binding/default/for-await-of-async-gen-var-async.template +/*--- +description: Elision accepts exhausted iterator (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [generator, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + [...] + 2. Return NormalCompletion(empty). + +---*/ +var iter = function*() {}(); +iter.next(); + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [iter]; +})(); + +async function *fn() { + for await (var [,] of asyncIter) { + + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elision.js b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elision.js new file mode 100644 index 0000000000..8a1d796ca4 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elision.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision.case +// - src/dstr-binding/default/for-await-of-async-gen-var-async.template +/*--- +description: Elision advances iterator (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [generator, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [g()]; +})(); + +async function *fn() { + for await (var [,] of asyncIter) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-empty.js b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-empty.js new file mode 100644 index 0000000000..793cdc441d --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-empty.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-empty.case +// - src/dstr-binding/default/for-await-of-async-gen-var-async.template +/*--- +description: No iteration occurs for an "empty" array binding pattern (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [generators, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [iter]; +})(); + +async function *fn() { + for await (var [] of asyncIter) { + assert.sameValue(iterations, 0); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-ary-elem.js b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-ary-elem.js new file mode 100644 index 0000000000..75116da7c1 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-ary-elem.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elem.case +// - src/dstr-binding/default/for-await-of-async-gen-var-async.template +/*--- +description: Rest element containing an array BindingElementList pattern (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[3, 4, 5]]; +})(); + +async function *fn() { + for await (var [...[x, y, z]] of asyncIter) { + assert.sameValue(x, 3); + assert.sameValue(y, 4); + assert.sameValue(z, 5); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-ary-elision.js b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-ary-elision.js new file mode 100644 index 0000000000..db5607c2d6 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-ary-elision.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elision.case +// - src/dstr-binding/default/for-await-of-async-gen-var-async.template +/*--- +description: Rest element containing an elision (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [generators, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [g()]; +})(); + +async function *fn() { + for await (var [...[,]] of asyncIter) { + assert.sameValue(first, 1); + assert.sameValue(second, 1); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-ary-empty.js b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-ary-empty.js new file mode 100644 index 0000000000..e1ecf8d8ec --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-ary-empty.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-empty.case +// - src/dstr-binding/default/for-await-of-async-gen-var-async.template +/*--- +description: Rest element containing an "empty" array pattern (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [generators, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [iter]; +})(); + +async function *fn() { + for await (var [...[]] of asyncIter) { + assert.sameValue(iterations, 1); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-ary-rest.js b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-ary-rest.js new file mode 100644 index 0000000000..76df2f222c --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-ary-rest.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-rest.case +// - src/dstr-binding/default/for-await-of-async-gen-var-async.template +/*--- +description: Rest element containing a rest element (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +var values = [1, 2, 3]; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [values]; +})(); + +async function *fn() { + for await (var [...[...x]] of asyncIter) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-id-elision.js b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-id-elision.js new file mode 100644 index 0000000000..d341b096a5 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-id-elision.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision.case +// - src/dstr-binding/default/for-await-of-async-gen-var-async.template +/*--- +description: Rest element following elision elements (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. +---*/ +var values = [1, 2, 3, 4, 5]; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [values]; +})(); + +async function *fn() { + for await (var [ , , ...x] of asyncIter) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 3); + assert.sameValue(x[1], 4); + assert.sameValue(x[2], 5); + assert.notSameValue(x, values); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-id-exhausted.js b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-id-exhausted.js new file mode 100644 index 0000000000..d6a9d18ee0 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-id-exhausted.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-exhausted.case +// - src/dstr-binding/default/for-await-of-async-gen-var-async.template +/*--- +description: RestElement applied to an exhausted iterator (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [Symbol.iterator, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + b. If iteratorRecord.[[done]] is true, then + i. If environment is undefined, return PutValue(lhs, A). + ii. Return InitializeReferencedBinding(lhs, A). + +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[1, 2]]; +})(); + +async function *fn() { + for await (var [, , ...x] of asyncIter) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 0); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-id.js b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-id.js new file mode 100644 index 0000000000..f9d74bf06e --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-id.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id.case +// - src/dstr-binding/default/for-await-of-async-gen-var-async.template +/*--- +description: Lone rest element (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat + [...] + f. Let status be CreateDataProperty(A, ToString (n), nextValue). + [...] +---*/ +var values = [1, 2, 3]; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [values]; +})(); + +async function *fn() { + for await (var [...x] of asyncIter) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-init-ary.js b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-init-ary.js new file mode 100644 index 0000000000..e30e423fb9 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-init-ary.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-ary.case +// - src/dstr-binding/default/for-await-of-async-gen-var-async.template +/*--- +description: Reset element (nested array pattern) does not support initializer (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +negative: + phase: early + type: SyntaxError +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function *fn() { + for await (var [...[ x ] = []] of asyncIter) { + + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-init-id.js b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-init-id.js new file mode 100644 index 0000000000..7d90f03364 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-init-id.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-id.case +// - src/dstr-binding/default/for-await-of-async-gen-var-async.template +/*--- +description: Reset element (identifier) does not support initializer (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +negative: + phase: early + type: SyntaxError +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function *fn() { + for await (var [...x = []] of asyncIter) { + + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-init-obj.js b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-init-obj.js new file mode 100644 index 0000000000..df323d0a8f --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-init-obj.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-obj.case +// - src/dstr-binding/default/for-await-of-async-gen-var-async.template +/*--- +description: Reset element (nested object pattern) does not support initializer (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +negative: + phase: early + type: SyntaxError +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[]]; +})(); + +async function *fn() { + for await (var [...{ x } = []] of asyncIter) { + + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-not-final-ary.js b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-not-final-ary.js new file mode 100644 index 0000000000..5b8668b12f --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-not-final-ary.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-ary.case +// - src/dstr-binding/default/for-await-of-async-gen-var-async.template +/*--- +description: Rest element (array binding pattern) may not be followed by any element (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +negative: + phase: early + type: SyntaxError +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[1, 2, 3]]; +})(); + +async function *fn() { + for await (var [...[x], y] of asyncIter) { + + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-not-final-id.js b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-not-final-id.js new file mode 100644 index 0000000000..c2aec63548 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-not-final-id.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-id.case +// - src/dstr-binding/default/for-await-of-async-gen-var-async.template +/*--- +description: Rest element (identifier) may not be followed by any element (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +negative: + phase: early + type: SyntaxError +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[1, 2, 3]]; +})(); + +async function *fn() { + for await (var [...x, y] of asyncIter) { + + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-not-final-obj.js b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-not-final-obj.js new file mode 100644 index 0000000000..3a095e909c --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-not-final-obj.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-obj.case +// - src/dstr-binding/default/for-await-of-async-gen-var-async.template +/*--- +description: Rest element (object binding pattern) may not be followed by any element (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +negative: + phase: early + type: SyntaxError +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[1, 2, 3]]; +})(); + +async function *fn() { + for await (var [...{ x }, y] of asyncIter) { + + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-obj-id.js b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-obj-id.js new file mode 100644 index 0000000000..ab1dc5f5a3 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-obj-id.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-id.case +// - src/dstr-binding/default/for-await-of-async-gen-var-async.template +/*--- +description: Rest element containing an object binding pattern (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[1, 2, 3]]; +})(); + +async function *fn() { + for await (var [...{ length }] of asyncIter) { + assert.sameValue(length, 3); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-obj-prop-id.js b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-obj-prop-id.js new file mode 100644 index 0000000000..aef73a7468 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-obj-prop-id.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-prop-id.case +// - src/dstr-binding/default/for-await-of-async-gen-var-async.template +/*--- +description: Rest element containing an object binding pattern (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +let length = "outer"; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [[7, 8, 9]]; +})(); + +async function *fn() { + for await (var [...{ 0: v, 1: w, 2: x, 3: y, length: z }] of asyncIter) { + assert.sameValue(v, 7); + assert.sameValue(w, 8); + assert.sameValue(x, 9); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + assert.sameValue(length, "outer", "the length prop is not set as a binding name"); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-empty.js b/test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-empty.js new file mode 100644 index 0000000000..ba538f7776 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-empty.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-empty.case +// - src/dstr-binding/default/for-await-of-async-gen-var-async.template +/*--- +description: No property access occurs for an "empty" object binding pattern (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ +var accessCount = 0; +var obj = Object.defineProperty({}, 'attr', { + get: function() { + accessCount += 1; + } +}); + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [obj]; +})(); + +async function *fn() { + for await (var {} of asyncIter) { + assert.sameValue(accessCount, 0); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-id-init-fn-name-arrow.js b/test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..9ef53e8836 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-id-init-fn-name-arrow.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-arrow.case +// - src/dstr-binding/default/for-await-of-async-gen-var-async.template +/*--- +description: SingleNameBinding assigns `name` to arrow functions (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{}]; +})(); + +async function *fn() { + for await (var { arrow = () => {} } of asyncIter) { + assert.sameValue(arrow.name, 'arrow'); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-id-init-fn-name-class.js b/test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-id-init-fn-name-class.js new file mode 100644 index 0000000000..ba481e7c38 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-id-init-fn-name-class.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-class.case +// - src/dstr-binding/default/for-await-of-async-gen-var-async.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{}]; +})(); + +async function *fn() { + for await (var { cls = class {}, xCls = class X {}, xCls2 = class { static name() {} } } of asyncIter) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + assert.notSameValue(xCls2.name, 'xCls2'); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-id-init-fn-name-cover.js b/test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-id-init-fn-name-cover.js new file mode 100644 index 0000000000..36d310ab1b --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-id-init-fn-name-cover.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-cover.case +// - src/dstr-binding/default/for-await-of-async-gen-var-async.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{}]; +})(); + +async function *fn() { + for await (var { cover = (function () {}), xCover = (0, function() {}) } of asyncIter) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-id-init-fn-name-fn.js b/test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-id-init-fn-name-fn.js new file mode 100644 index 0000000000..8f12ee8edf --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-id-init-fn-name-fn.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-fn.case +// - src/dstr-binding/default/for-await-of-async-gen-var-async.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{}]; +})(); + +async function *fn() { + for await (var { fn = function () {}, xFn = function x() {} } of asyncIter) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-id-init-fn-name-gen.js b/test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-id-init-fn-name-gen.js new file mode 100644 index 0000000000..f3a9bd8545 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-id-init-fn-name-gen.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-gen.case +// - src/dstr-binding/default/for-await-of-async-gen-var-async.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{}]; +})(); + +async function *fn() { + for await (var { gen = function* () {}, xGen = function* x() {} } of asyncIter) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-id-init-skipped.js b/test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-id-init-skipped.js new file mode 100644 index 0000000000..2767600537 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-id-init-skipped.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-skipped.case +// - src/dstr-binding/default/for-await-of-async-gen-var-async.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{ w: null, x: 0, y: false, z: '' }]; +})(); + +async function *fn() { + for await (var { w = counter(), x = counter(), y = counter(), z = counter() } of asyncIter) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-id-trailing-comma.js b/test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-id-trailing-comma.js new file mode 100644 index 0000000000..8a8a604609 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-id-trailing-comma.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-trailing-comma.case +// - src/dstr-binding/default/for-await-of-async-gen-var-async.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{ x: 23 }]; +})(); + +async function *fn() { + for await (var { x, } of asyncIter) { + assert.sameValue(x, 23); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-prop-ary-init.js b/test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-prop-ary-init.js new file mode 100644 index 0000000000..d43318b9f9 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-prop-ary-init.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-init.case +// - src/dstr-binding/default/for-await-of-async-gen-var-async.template +/*--- +description: Object binding pattern with "nested" array binding pattern using initializer (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{}]; +})(); + +async function *fn() { + for await (var { w: [x, y, z] = [4, 5, 6] } of asyncIter) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-prop-ary-trailing-comma.js b/test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-prop-ary-trailing-comma.js new file mode 100644 index 0000000000..a32d543f92 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-prop-ary-trailing-comma.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-trailing-comma.case +// - src/dstr-binding/default/for-await-of-async-gen-var-async.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{ x: [45] }]; +})(); + +async function *fn() { + for await (var { x: [y], } of asyncIter) { + assert.sameValue(y,45); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-prop-ary.js b/test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-prop-ary.js new file mode 100644 index 0000000000..b741c3e432 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-prop-ary.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary.case +// - src/dstr-binding/default/for-await-of-async-gen-var-async.template +/*--- +description: Object binding pattern with "nested" array binding pattern not using initializer (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{ w: [7, undefined, ] }]; +})(); + +async function *fn() { + for await (var { w: [x, y, z] = [4, 5, 6] } of asyncIter) { + assert.sameValue(x, 7); + assert.sameValue(y, undefined); + assert.sameValue(z, undefined); + + assert.throws(ReferenceError, function() { + w; + }); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-prop-id-init-skipped.js b/test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-prop-id-init-skipped.js new file mode 100644 index 0000000000..fd7832b9a6 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-prop-id-init-skipped.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case +// - src/dstr-binding/default/for-await-of-async-gen-var-async.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{ s: null, u: 0, w: false, y: '' }]; +})(); + +async function *fn() { + for await (var { s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() } of asyncIter) { + assert.sameValue(t, null); + assert.sameValue(v, 0); + assert.sameValue(x, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + assert.throws(ReferenceError, function() { + s; + }); + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-prop-id-init.js b/test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-prop-id-init.js new file mode 100644 index 0000000000..608374835c --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-prop-id-init.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init.case +// - src/dstr-binding/default/for-await-of-async-gen-var-async.template +/*--- +description: Binding as specified via property name, identifier, and initializer (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{ }]; +})(); + +async function *fn() { + for await (var { x: y = 33 } of asyncIter) { + assert.sameValue(y, 33); + assert.throws(ReferenceError, function() { + x; + }); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-prop-id-trailing-comma.js b/test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-prop-id-trailing-comma.js new file mode 100644 index 0000000000..90e557ab3d --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-prop-id-trailing-comma.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-trailing-comma.case +// - src/dstr-binding/default/for-await-of-async-gen-var-async.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{ x: 23 }]; +})(); + +async function *fn() { + for await (var { x: y, } of asyncIter) { + assert.sameValue(y, 23); + + assert.throws(ReferenceError, function() { + x; + }); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-prop-id.js b/test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-prop-id.js new file mode 100644 index 0000000000..90fc74e89e --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-prop-id.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id.case +// - src/dstr-binding/default/for-await-of-async-gen-var-async.template +/*--- +description: Binding as specified via property name and identifier (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{ x: 23 }]; +})(); + +async function *fn() { + for await (var { x: y } of asyncIter) { + assert.sameValue(y, 23); + assert.throws(ReferenceError, function() { + x; + }); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-prop-obj-init.js b/test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-prop-obj-init.js new file mode 100644 index 0000000000..3330515154 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-prop-obj-init.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-init.case +// - src/dstr-binding/default/for-await-of-async-gen-var-async.template +/*--- +description: Object binding pattern with "nested" object binding pattern using initializer (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{ w: undefined }]; +})(); + +async function *fn() { + for await (var { w: { x, y, z } = { x: 4, y: 5, z: 6 } } of asyncIter) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-prop-obj.js b/test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-prop-obj.js new file mode 100644 index 0000000000..b4b5d99369 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-prop-obj.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj.case +// - src/dstr-binding/default/for-await-of-async-gen-var-async.template +/*--- +description: Object binding pattern with "nested" object binding pattern not using initializer (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{ w: { x: undefined, z: 7 } }]; +})(); + +async function *fn() { + for await (var { w: { x, y, z } = { x: 4, y: 5, z: 6 } } of asyncIter) { + assert.sameValue(x, undefined); + assert.sameValue(y, undefined); + assert.sameValue(z, 7); + + assert.throws(ReferenceError, function() { + w; + }); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-rest-getter.js b/test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-rest-getter.js new file mode 100644 index 0000000000..5eeb41d48a --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-rest-getter.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-getter.case +// - src/dstr-binding/default/for-await-of-async-gen-var-async.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [object-rest, destructuring-binding, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] +---*/ +var count = 0; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{ get v() { count++; return 2; } }]; +})(); + +async function *fn() { + for await (var {...x} of asyncIter) { + assert.sameValue(x.v, 2); + assert.sameValue(count, 1); + + verifyEnumerable(x, "v"); + verifyWritable(x, "v"); + verifyConfigurable(x, "v"); + + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-rest-nested-obj.js b/test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-rest-nested-obj.js new file mode 100644 index 0000000000..cd9062e905 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-rest-nested-obj.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-nested-obj.case +// - src/dstr-binding/default/for-await-of-async-gen-var-async.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment. (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [object-rest, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] +---*/ +var obj = {a: 3, b: 4}; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{a: 1, b: 2, c: 3, d: 4, e: 5}]; +})(); + +async function *fn() { + for await (var {a, b, ...{c, e}} of asyncIter) { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + assert.sameValue(e, 5); + + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-rest-obj-nested-rest.js b/test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-rest-obj-nested-rest.js new file mode 100644 index 0000000000..b81c71e52a --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-rest-obj-nested-rest.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-nested-rest.case +// - src/dstr-binding/default/for-await-of-async-gen-var-async.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment and object rest desconstruction is allowed in that case. (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [object-rest, destructuring-binding, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{a: 1, b: 2, c: 3, d: 4, e: 5}]; +})(); + +async function *fn() { + for await (var {a, b, ...{c, ...rest}} of asyncIter) { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + + assert.sameValue(rest.d, 4); + assert.sameValue(rest.e, 5); + + verifyEnumerable(rest, "d"); + verifyWritable(rest, "d"); + verifyConfigurable(rest, "d"); + + verifyEnumerable(rest, "e"); + verifyWritable(rest, "e"); + verifyConfigurable(rest, "e"); + + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-rest-obj-own-property.js b/test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-rest-obj-own-property.js new file mode 100644 index 0000000000..db8d2a4b4d --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-rest-obj-own-property.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-own-property.case +// - src/dstr-binding/default/for-await-of-async-gen-var-async.template +/*--- +description: Rest object contains just soruce object's own properties (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [object-rest, destructuring-binding, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] +---*/ +var o = Object.create({ x: 1, y: 2 }); +o.z = 3; + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [o]; +})(); + +async function *fn() { + for await (var { x, ...{y , z} } of asyncIter) { + assert.sameValue(x, 1); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-rest-skip-non-enumerable.js b/test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..0f5545826c --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-rest-skip-non-enumerable.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-skip-non-enumerable.case +// - src/dstr-binding/default/for-await-of-async-gen-var-async.template +/*--- +description: Rest object doesn't contain non-enumerable properties (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [object-rest, destructuring-binding, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] +---*/ +var o = {a: 3, b: 4}; +Object.defineProperty(o, "x", { value: 4, enumerable: false }); + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [o]; +})(); + +async function *fn() { + for await (var {...rest} of asyncIter) { + assert.sameValue(rest.a, 3); + assert.sameValue(rest.b, 4); + assert.sameValue(rest.x, undefined); + + verifyEnumerable(rest, "a"); + verifyWritable(rest, "a"); + verifyConfigurable(rest, "a"); + + verifyEnumerable(rest, "b"); + verifyWritable(rest, "b"); + verifyConfigurable(rest, "b"); + + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-rest-val-obj.js b/test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-rest-val-obj.js new file mode 100644 index 0000000000..52dcba15fe --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-rest-val-obj.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-val-obj.case +// - src/dstr-binding/default/for-await-of-async-gen-var-async.template +/*--- +description: Rest object contains just unextracted data (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [object-rest, destructuring-binding, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [{x: 1, y: 2, a: 5, b: 3}]; +})(); + +async function *fn() { + for await (var {a, b, ...rest} of asyncIter) { + assert.sameValue(rest.x, 1); + assert.sameValue(rest.y, 2); + assert.sameValue(rest.a, undefined); + assert.sameValue(rest.b, undefined); + + verifyEnumerable(rest, "x"); + verifyWritable(rest, "x"); + verifyConfigurable(rest, "x"); + + verifyEnumerable(rest, "y"); + verifyWritable(rest, "y"); + verifyConfigurable(rest, "y"); + + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE);