diff --git a/src/dstr-binding/error/for-await-of-async-func-const.template b/src/dstr-binding/error/for-await-of-async-func-const.template new file mode 100644 index 0000000000000000000000000000000000000000..dc2fc2499b11c913fd6e5a0322eb00959493c2e1 --- /dev/null +++ b/src/dstr-binding/error/for-await-of-async-func-const.template @@ -0,0 +1,48 @@ +// Copyright (C) 2017 the V8 project authors. 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- +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. + [...] +---*/ + +async function fn() { + for await (const /*{ elems }*/ of [/*{ vals }*/]) { + return; + } +} + +fn() + .then(_ => { throw new Test262Error("Expected async function to reject, but resolved."); }, ({ constructor }) => assert.sameValue(constructor, /*{ error }*/)) + .then($DONE, $DONE); + diff --git a/src/dstr-binding/error/for-await-of-async-func-let.template b/src/dstr-binding/error/for-await-of-async-func-let.template new file mode 100644 index 0000000000000000000000000000000000000000..291b51a6480c652c20b1888be8a3feff9a08f36a --- /dev/null +++ b/src/dstr-binding/error/for-await-of-async-func-let.template @@ -0,0 +1,48 @@ +// Copyright (C) 2017 the V8 project authors. 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- +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. + [...] +---*/ + +async function fn() { + for await (let /*{ elems }*/ of [/*{ vals }*/]) { + return; + } +} + +fn() + .then(_ => { throw new Test262Error("Expected async function to reject, but resolved."); }, ({ constructor }) => assert.sameValue(constructor, /*{ error }*/)) + .then($DONE, $DONE); + diff --git a/src/dstr-binding/error/for-await-of-async-func-var.template b/src/dstr-binding/error/for-await-of-async-func-var.template new file mode 100644 index 0000000000000000000000000000000000000000..ab9ae97124bb250ca8ea982adff91bdb8a4a5965 --- /dev/null +++ b/src/dstr-binding/error/for-await-of-async-func-var.template @@ -0,0 +1,47 @@ +// Copyright (C) 2017 the V8 project authors. 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- +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 ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] +---*/ + +async function fn() { + for await (var /*{ elems }*/ of [/*{ vals }*/]) { + return; + } +} + +fn() + .then(_ => { throw new Test262Error("Expected async function to reject, but resolved."); }, ({ constructor }) => assert.sameValue(constructor, /*{ error }*/)) + .then($DONE, $DONE); diff --git a/src/dstr-binding/error/for-await-of-async-gen-const.template b/src/dstr-binding/error/for-await-of-async-gen-const.template new file mode 100644 index 0000000000000000000000000000000000000000..4f4f2deb0fbb60915bacf188f5bb3a7599436958 --- /dev/null +++ b/src/dstr-binding/error/for-await-of-async-gen-const.template @@ -0,0 +1,48 @@ +// Copyright (C) 2017 the V8 project authors. 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- +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. + [...] +---*/ + +async function * gen() { + for await (const /*{ elems }*/ of [/*{ vals }*/]) { + return; + } +} + +gen().next() + .then(_ => { throw new Test262Error("Expected async function to reject, but resolved."); }, ({ constructor }) => assert.sameValue(constructor, /*{ error }*/)) + .then($DONE, $DONE); + diff --git a/src/dstr-binding/error/for-await-of-async-gen-let.template b/src/dstr-binding/error/for-await-of-async-gen-let.template new file mode 100644 index 0000000000000000000000000000000000000000..38c2f00fbc338c6e819414103c18465438cd8cb9 --- /dev/null +++ b/src/dstr-binding/error/for-await-of-async-gen-let.template @@ -0,0 +1,47 @@ +// Copyright (C) 2017 the V8 project authors. 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- +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 ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] +---*/ + +async function * gen() { + for await (let /*{ elems }*/ of [/*{ vals }*/]) { + return; + } +} + +gen().next() + .then(_ => { throw new Test262Error("Expected async function to reject, but resolved."); }, ({ constructor }) => assert.sameValue(constructor, /*{ error }*/)) + .then($DONE, $DONE); diff --git a/src/dstr-binding/error/for-await-of-async-gen-var.template b/src/dstr-binding/error/for-await-of-async-gen-var.template new file mode 100644 index 0000000000000000000000000000000000000000..41f9d08a2722f2f01e2cc88e1d5bc2351bbb2fbe --- /dev/null +++ b/src/dstr-binding/error/for-await-of-async-gen-var.template @@ -0,0 +1,48 @@ +// Copyright (C) 2017 the V8 project authors. 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- +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. + [...] +---*/ + +async function * gen() { + for await (var /*{ elems }*/ of [/*{ vals }*/]) { + return; + } +} + +gen().next() + .then(_ => { throw new Test262Error("Expected async function to reject, but resolved."); }, ({ constructor }) => assert.sameValue(constructor, /*{ error }*/)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-const-ary-init-iter-get-err.js b/test/language/statements/for-await-of/async-func-dstr-const-ary-init-iter-get-err.js new file mode 100644 index 0000000000000000000000000000000000000000..9da24dcf7e82884248cad369d60acf3390833c04 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-ary-init-iter-get-err.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/for-await-of-async-func-const.template +/*--- +description: Abrupt completion returned by GetIterator (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 + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). + +---*/ +var iter = {}; +iter[Symbol.iterator] = function() { + throw new Test262Error(); +}; + +async function fn() { + for await (const [x] of [iter]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-ary-val-null.js b/test/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000000000000000000000000000000000..bb387d3285d598e9b0eebf8061b87b3d198e49d9 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-val-null.case +// - src/dstr-binding/error/for-await-of-async-func-const.template +/*--- +description: Nested array destructuring with a null 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 + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). +---*/ + +async function fn() { + for await (const [[x]] of [[null]]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-init-throws.js b/test/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..bd15ae9270f8fceb0803dfd188efa422bddad581 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-throws.case +// - src/dstr-binding/error/for-await-of-async-func-const.template +/*--- +description: Destructuring initializer returns an abrupt completion (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: 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). +---*/ + +async function fn() { + for await (const [x = (function() { throw new Test262Error(); })()] of [[undefined]]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-init-unresolvable.js b/test/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..699df9e6a7429663782fc81b53bb3e87eff0a03f --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-unresolvable.case +// - src/dstr-binding/error/for-await-of-async-func-const.template +/*--- +description: Destructuring initializer is an unresolvable reference (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: 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). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +async function fn() { + for await (const [ x = unresolvableReference ] of [[]]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, ReferenceError)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-iter-step-err.js b/test/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..b0f6240e7217d4bcd0a5b8e77f02f48a4ad4dc6a --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-step-err.case +// - src/dstr-binding/error/for-await-of-async-func-const.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: 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). +---*/ +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + throw new Test262Error(); + } + }; +}; + +async function fn() { + for await (const [x] of [g]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-iter-val-err.js b/test/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000000000000000000000000000000000..201883140d551dd4a3e9c0f63e541ec933fbf1fb --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-err.case +// - src/dstr-binding/error/for-await-of-async-func-const.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: 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). +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +async function fn() { + for await (const [x] of [g]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-obj-val-null.js b/test/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000000000000000000000000000000000..5dbb8aae09cf77d3defba1cf9674ed6e1ce18132 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-null.case +// - src/dstr-binding/error/for-await-of-async-func-const.template +/*--- +description: Nested object destructuring with a null 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 + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + +async function fn() { + for await (const [{ x }] of [[null]]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-obj-val-undef.js b/test/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000000000000000000000000000000000..f57a737bfba6d3c29a643b9ffe0df8130ef026c3 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-undef.case +// - src/dstr-binding/error/for-await-of-async-func-const.template +/*--- +description: Nested object destructuring with a value of `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 + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + +async function fn() { + for await (const [{ x }] of [[]]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elision-step-err.js b/test/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..fd42bfbe9b6fa00e2287199fd30ab76615dd3b70 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elision-step-err.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/for-await-of-async-func-const.template +/*--- +description: Elision advances iterator and forwards abrupt completions (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). + +---*/ +var following = 0; +var iter =function* () { + throw new Test262Error(); + following += 1; +}(); + +async function fn() { + for await (const [,] of [iter]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); diff --git a/test/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-id-elision-next-err.js b/test/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000000000000000000000000000000000..331420049841884c9ebfd2eb219c732574ee4325 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision-next-err.case +// - src/dstr-binding/error/for-await-of-async-func-const.template +/*--- +description: Rest element following elision elements (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 : [ 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 iter = (function*() { throw new Test262Error(); })(); + +async function fn() { + for await (const [, ...x] of [iter]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-id-iter-step-err.js b/test/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..5c428cb60bedfc085998d77dd020e4ae8f1116dc --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case +// - src/dstr-binding/error/for-await-of-async-func-const.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (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 : ... 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, + a. If iteratorRecord.[[done]] is false, + i. Let next be IteratorStep(iteratorRecord.[[iterator]]). + ii. If next is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(next). + +---*/ +var first = 0; +var second = 0; +var iter = function*() { + first += 1; + throw new Test262Error(); + second += 1; +}(); + +async function fn() { + for await (const [...x] of [iter]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + + +iter.next(); +assert.sameValue(first, 1); +assert.sameValue(second, 0, 'Iterator is closed following abrupt completion.'); diff --git a/test/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-id-iter-val-err.js b/test/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000000000000000000000000000000000..3e8d5d7a67b1c8c766c578ebd8082c5af97d2290 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-val-err.case +// - src/dstr-binding/error/for-await-of-async-func-const.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (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, + [...] + c. Let nextValue be IteratorValue(next). + d. If nextValue is an abrupt completion, set iteratorRecord.[[done]] to + true. + e. ReturnIfAbrupt(nextValue). + +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +async function fn() { + for await (const [...x] of [iter]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-const-obj-init-null.js b/test/language/statements/for-await-of/async-func-dstr-const-obj-init-null.js new file mode 100644 index 0000000000000000000000000000000000000000..ea28e8223a1ef6fe259e8a61ef2f3c655c24a094 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-obj-init-null.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/for-await-of-async-func-const.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is 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). +---*/ + +async function fn() { + for await (const {} of [null]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-const-obj-init-undefined.js b/test/language/statements/for-await-of/async-func-dstr-const-obj-init-undefined.js new file mode 100644 index 0000000000000000000000000000000000000000..60afada464b24126d65a7e8e28bf6794a7ec40e1 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-obj-init-undefined.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/for-await-of-async-func-const.template +/*--- +description: Value specifed for object binding pattern must be object coercible (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. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +async function fn() { + for await (const {} of [undefined]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-id-get-value-err.js b/test/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000000000000000000000000000000000..e5f578fd105c120c851ec765eef72ac4435beedf --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-id-get-value-err.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-get-value-err.case +// - src/dstr-binding/error/for-await-of-async-func-const.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: 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 + + [...] + 4. Let v be GetV(value, propertyName). + 5. ReturnIfAbrupt(v). +---*/ +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + +async function fn() { + for await (const { poisoned } of [poisonedProperty]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-id-init-throws.js b/test/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..acf8199fc58d428c3fb436d0f27711864ba70d2e --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-id-init-throws.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/for-await-of-async-func-const.template +/*--- +description: Error thrown when evaluating the 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 + + [...] + 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). +---*/ +function thrower() { + throw new Test262Error(); +} + +async function fn() { + for await (const { x = thrower() } of [{}]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-id-init-unresolvable.js b/test/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..160c8fd48e58e4e3a8d3ec14fabefc76dcb09c19 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/for-await-of-async-func-const.template +/*--- +description: Destructuring initializer is an unresolvable reference (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: 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 + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +async function fn() { + for await (const { x = unresolvableReference } of [{}]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, ReferenceError)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-list-err.js b/test/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-list-err.js new file mode 100644 index 0000000000000000000000000000000000000000..1354691d8e042b1abf29fbd837538ad67aa53662 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-list-err.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/for-await-of-async-func-const.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: 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 + + BindingPropertyList : BindingPropertyList , BindingProperty + + 1. Let status be the result of performing BindingInitialization for + BindingPropertyList using value and environment as arguments. + 2. ReturnIfAbrupt(status). +---*/ +var initCount = 0; +function thrower() { + throw new Test262Error(); +} + +async function fn() { + for await (const { a, b = thrower(), c = ++initCount } of [{}]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + + +assert.sameValue(initCount, 0); diff --git a/test/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-ary-value-null.js b/test/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000000000000000000000000000000000..1bfc8b26af0f728c7362126390b906bc0c248911 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-value-null.case +// - src/dstr-binding/error/for-await-of-async-func-const.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` 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.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. +---*/ + +async function fn() { + for await (const { w: [x, y, z] = [4, 5, 6] } of [{ w: null }]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-eval-err.js b/test/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000000000000000000000000000000000..560b7b727ffa4b825e2f44fc21876ab4725ab4c9 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-eval-err.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/for-await-of-async-func-const.template +/*--- +description: Evaluation of property name returns an abrupt completion (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: 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 + + BindingProperty : PropertyName : BindingElement + + 1. Let P be the result of evaluating PropertyName + 2. ReturnIfAbrupt(P). +---*/ +function thrower() { + throw new Test262Error(); +} + +async function fn() { + for await (const { [thrower()]: x } of [{}]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-id-get-value-err.js b/test/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000000000000000000000000000000000..2dd96d03bfe1a50df73de2913cf2ef1a2b29cec1 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-get-value-err.case +// - src/dstr-binding/error/for-await-of-async-func-const.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: 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 + + 1. Let v be GetV(value, propertyName). + 2. ReturnIfAbrupt(v). +---*/ +var initEvalCount = 0; +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + +async function fn() { + for await (const { poisoned: x = ++initEvalCount } of [poisonedProperty]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + + +assert.sameValue(initEvalCount, 0); diff --git a/test/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-id-init-throws.js b/test/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..9b3445c284c51565c4626d7bb985feac401e1b38 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-throws.case +// - src/dstr-binding/error/for-await-of-async-func-const.template +/*--- +description: Error thrown when evaluating the 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 + + BindingElement : BindingPattern Initializeropt + + [...] + 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). +---*/ +function thrower() { + throw new Test262Error(); +} + +async function fn() { + for await (const { x: y = thrower() } of [{}]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-id-init-unresolvable.js b/test/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..f8b2c3f3aed8bdacd079f6393aa3bd1701d0249f --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-unresolvable.case +// - src/dstr-binding/error/for-await-of-async-func-const.template +/*--- +description: Destructuring initializer is an unresolvable reference (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: 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 + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +async function fn() { + for await (const { x: y = unresolvableReference } of [{}]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, ReferenceError)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-obj-value-null.js b/test/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000000000000000000000000000000000..fc16686aa5a11e570fb85d60d0b84f43333c5595 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-null.case +// - src/dstr-binding/error/for-await-of-async-func-const.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` 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.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. +---*/ + +async function fn() { + for await (const { w: { x, y, z } = { x: 4, y: 5, z: 6 } } of [{ w: null }]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-obj-value-undef.js b/test/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000000000000000000000000000000000..90450b19cb719dbf437b8245c3385e4fb0eb84bc --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-undef.case +// - src/dstr-binding/error/for-await-of-async-func-const.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` 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.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. +---*/ + +async function fn() { + for await (const { w: { x, y, z } = undefined } of [{ }]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-let-ary-init-iter-get-err.js b/test/language/statements/for-await-of/async-func-dstr-let-ary-init-iter-get-err.js new file mode 100644 index 0000000000000000000000000000000000000000..12b62c47722bba713dce4df4a65f8f8c92b8d66b --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-ary-init-iter-get-err.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/for-await-of-async-func-let.template +/*--- +description: Abrupt completion returned by GetIterator (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 + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). + +---*/ +var iter = {}; +iter[Symbol.iterator] = function() { + throw new Test262Error(); +}; + +async function fn() { + for await (let [x] of [iter]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-ary-val-null.js b/test/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000000000000000000000000000000000..b87926ec433ea88fb6230793457c45b861b9683d --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-val-null.case +// - src/dstr-binding/error/for-await-of-async-func-let.template +/*--- +description: Nested array destructuring with a null 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 + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). +---*/ + +async function fn() { + for await (let [[x]] of [[null]]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-init-throws.js b/test/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..f9b468dac18b2e44a8f2125552ef4f7ea0a5b8f5 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-throws.case +// - src/dstr-binding/error/for-await-of-async-func-let.template +/*--- +description: Destructuring initializer returns an abrupt completion (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: 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). +---*/ + +async function fn() { + for await (let [x = (function() { throw new Test262Error(); })()] of [[undefined]]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-init-unresolvable.js b/test/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..d683743e9cb0d806f6ea0bcb5824936463e2cf24 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-unresolvable.case +// - src/dstr-binding/error/for-await-of-async-func-let.template +/*--- +description: Destructuring initializer is an unresolvable reference (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: 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). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +async function fn() { + for await (let [ x = unresolvableReference ] of [[]]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, ReferenceError)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-iter-step-err.js b/test/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..42e47aa5bdc579d5cc7201581bae43981b20bd28 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-step-err.case +// - src/dstr-binding/error/for-await-of-async-func-let.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: 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). +---*/ +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + throw new Test262Error(); + } + }; +}; + +async function fn() { + for await (let [x] of [g]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-iter-val-err.js b/test/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000000000000000000000000000000000..ebf0dbe427a0b9c38336e2b5e65d126119b20396 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-err.case +// - src/dstr-binding/error/for-await-of-async-func-let.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: 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). +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +async function fn() { + for await (let [x] of [g]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-obj-val-null.js b/test/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000000000000000000000000000000000..3e9dcbe7cd029bc85b4c0d36ba3a6ea78285df83 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-null.case +// - src/dstr-binding/error/for-await-of-async-func-let.template +/*--- +description: Nested object destructuring with a null 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 + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + +async function fn() { + for await (let [{ x }] of [[null]]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-obj-val-undef.js b/test/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000000000000000000000000000000000..10178b11e8823949d16e69207412c57c33b9108e --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-undef.case +// - src/dstr-binding/error/for-await-of-async-func-let.template +/*--- +description: Nested object destructuring with a value of `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 + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + +async function fn() { + for await (let [{ x }] of [[]]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elision-step-err.js b/test/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..1cf324585cfcbee9b3683b97da69c5606ea52135 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elision-step-err.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/for-await-of-async-func-let.template +/*--- +description: Elision advances iterator and forwards abrupt completions (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). + +---*/ +var following = 0; +var iter =function* () { + throw new Test262Error(); + following += 1; +}(); + +async function fn() { + for await (let [,] of [iter]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); diff --git a/test/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-id-elision-next-err.js b/test/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000000000000000000000000000000000..73ccf728c44c00522dbd68718318d4ff07204973 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision-next-err.case +// - src/dstr-binding/error/for-await-of-async-func-let.template +/*--- +description: Rest element following elision elements (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 : [ 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 iter = (function*() { throw new Test262Error(); })(); + +async function fn() { + for await (let [, ...x] of [iter]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-id-iter-step-err.js b/test/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..9bc64fa0088e04555f1ee7fabb28dccb07b456f6 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case +// - src/dstr-binding/error/for-await-of-async-func-let.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (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 : ... 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, + a. If iteratorRecord.[[done]] is false, + i. Let next be IteratorStep(iteratorRecord.[[iterator]]). + ii. If next is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(next). + +---*/ +var first = 0; +var second = 0; +var iter = function*() { + first += 1; + throw new Test262Error(); + second += 1; +}(); + +async function fn() { + for await (let [...x] of [iter]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + + +iter.next(); +assert.sameValue(first, 1); +assert.sameValue(second, 0, 'Iterator is closed following abrupt completion.'); diff --git a/test/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-id-iter-val-err.js b/test/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000000000000000000000000000000000..511fa2bb478f320919316daa3df745a478958891 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-val-err.case +// - src/dstr-binding/error/for-await-of-async-func-let.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (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, + [...] + c. Let nextValue be IteratorValue(next). + d. If nextValue is an abrupt completion, set iteratorRecord.[[done]] to + true. + e. ReturnIfAbrupt(nextValue). + +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +async function fn() { + for await (let [...x] of [iter]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-let-obj-init-null.js b/test/language/statements/for-await-of/async-func-dstr-let-obj-init-null.js new file mode 100644 index 0000000000000000000000000000000000000000..955bd17e8371a2f9ae82306225c015815dd15930 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-obj-init-null.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/for-await-of-async-func-let.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is 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). +---*/ + +async function fn() { + for await (let {} of [null]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-let-obj-init-undefined.js b/test/language/statements/for-await-of/async-func-dstr-let-obj-init-undefined.js new file mode 100644 index 0000000000000000000000000000000000000000..450b7227f29a4948d6bc7ab8612e7afb59d446eb --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-obj-init-undefined.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/for-await-of-async-func-let.template +/*--- +description: Value specifed for object binding pattern must be object coercible (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. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +async function fn() { + for await (let {} of [undefined]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-id-get-value-err.js b/test/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000000000000000000000000000000000..1e77d91be6e9dcd51426939365ca35811c95e49d --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-id-get-value-err.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-get-value-err.case +// - src/dstr-binding/error/for-await-of-async-func-let.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: 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 + + [...] + 4. Let v be GetV(value, propertyName). + 5. ReturnIfAbrupt(v). +---*/ +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + +async function fn() { + for await (let { poisoned } of [poisonedProperty]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-id-init-throws.js b/test/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..3fbf30fb2de54ae8fb520d75297fed1cc48446a3 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-id-init-throws.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/for-await-of-async-func-let.template +/*--- +description: Error thrown when evaluating the 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 + + [...] + 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). +---*/ +function thrower() { + throw new Test262Error(); +} + +async function fn() { + for await (let { x = thrower() } of [{}]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-id-init-unresolvable.js b/test/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..180a4bf7657881a45a0410bedd24e51883a689cf --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/for-await-of-async-func-let.template +/*--- +description: Destructuring initializer is an unresolvable reference (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: 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 + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +async function fn() { + for await (let { x = unresolvableReference } of [{}]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, ReferenceError)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-list-err.js b/test/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-list-err.js new file mode 100644 index 0000000000000000000000000000000000000000..e52ef1ce70600d4d7272a5c900814fa167c91571 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-list-err.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/for-await-of-async-func-let.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: 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 + + BindingPropertyList : BindingPropertyList , BindingProperty + + 1. Let status be the result of performing BindingInitialization for + BindingPropertyList using value and environment as arguments. + 2. ReturnIfAbrupt(status). +---*/ +var initCount = 0; +function thrower() { + throw new Test262Error(); +} + +async function fn() { + for await (let { a, b = thrower(), c = ++initCount } of [{}]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + + +assert.sameValue(initCount, 0); diff --git a/test/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-ary-value-null.js b/test/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000000000000000000000000000000000..9e5b06c3f9f218f26fc1365851b02b0ffc130645 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-value-null.case +// - src/dstr-binding/error/for-await-of-async-func-let.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` 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.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. +---*/ + +async function fn() { + for await (let { w: [x, y, z] = [4, 5, 6] } of [{ w: null }]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-eval-err.js b/test/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000000000000000000000000000000000..783753532ded8480dbc7a8bb9fd78a82809d98bb --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-eval-err.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/for-await-of-async-func-let.template +/*--- +description: Evaluation of property name returns an abrupt completion (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: 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 + + BindingProperty : PropertyName : BindingElement + + 1. Let P be the result of evaluating PropertyName + 2. ReturnIfAbrupt(P). +---*/ +function thrower() { + throw new Test262Error(); +} + +async function fn() { + for await (let { [thrower()]: x } of [{}]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-id-get-value-err.js b/test/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000000000000000000000000000000000..426855dcace6cbac88971053cbbd8651874dd0f4 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-get-value-err.case +// - src/dstr-binding/error/for-await-of-async-func-let.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: 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 + + 1. Let v be GetV(value, propertyName). + 2. ReturnIfAbrupt(v). +---*/ +var initEvalCount = 0; +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + +async function fn() { + for await (let { poisoned: x = ++initEvalCount } of [poisonedProperty]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + + +assert.sameValue(initEvalCount, 0); diff --git a/test/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-id-init-throws.js b/test/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..9c769ad08e77f14add1daca657112c34a1dc0154 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-throws.case +// - src/dstr-binding/error/for-await-of-async-func-let.template +/*--- +description: Error thrown when evaluating the 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 + + BindingElement : BindingPattern Initializeropt + + [...] + 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). +---*/ +function thrower() { + throw new Test262Error(); +} + +async function fn() { + for await (let { x: y = thrower() } of [{}]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-id-init-unresolvable.js b/test/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..31ecf590f729841a85445e77e9de606bc2877cfc --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-unresolvable.case +// - src/dstr-binding/error/for-await-of-async-func-let.template +/*--- +description: Destructuring initializer is an unresolvable reference (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: 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 + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +async function fn() { + for await (let { x: y = unresolvableReference } of [{}]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, ReferenceError)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-obj-value-null.js b/test/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000000000000000000000000000000000..214ab9ad23a739fc7c6380f3f162cce612fe90cd --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-null.case +// - src/dstr-binding/error/for-await-of-async-func-let.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` 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.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. +---*/ + +async function fn() { + for await (let { w: { x, y, z } = { x: 4, y: 5, z: 6 } } of [{ w: null }]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-obj-value-undef.js b/test/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000000000000000000000000000000000..83d4fe737b5c99da036738b6f67b5d27d19a94af --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-undef.case +// - src/dstr-binding/error/for-await-of-async-func-let.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` 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.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. +---*/ + +async function fn() { + for await (let { w: { x, y, z } = undefined } of [{ }]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-var-ary-init-iter-get-err.js b/test/language/statements/for-await-of/async-func-dstr-var-ary-init-iter-get-err.js new file mode 100644 index 0000000000000000000000000000000000000000..cfa5cb4bfe4f3d63d3c7eaa65d77f6d302c2ac2a --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-ary-init-iter-get-err.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/for-await-of-async-func-var.template +/*--- +description: Abrupt completion returned by GetIterator (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 ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: 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 + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). + +---*/ +var iter = {}; +iter[Symbol.iterator] = function() { + throw new Test262Error(); +}; + +async function fn() { + for await (var [x] of [iter]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-ary-val-null.js b/test/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000000000000000000000000000000000..6d255ef275bcb2174f6ffc60ce4bebd82fc9457f --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-val-null.case +// - src/dstr-binding/error/for-await-of-async-func-var.template +/*--- +description: Nested array destructuring with a null 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 ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: 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 : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). +---*/ + +async function fn() { + for await (var [[x]] of [[null]]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-init-throws.js b/test/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..50dfb1f4a4a3e4be54516db0afe64b8bceb89666 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-throws.case +// - src/dstr-binding/error/for-await-of-async-func-var.template +/*--- +description: Destructuring initializer returns an abrupt completion (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: 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). +---*/ + +async function fn() { + for await (var [x = (function() { throw new Test262Error(); })()] of [[undefined]]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-init-unresolvable.js b/test/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..8843287483ea22279a58a05bd01d8f559940107c --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-unresolvable.case +// - src/dstr-binding/error/for-await-of-async-func-var.template +/*--- +description: Destructuring initializer is an unresolvable reference (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: 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). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +async function fn() { + for await (var [ x = unresolvableReference ] of [[]]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, ReferenceError)) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-iter-step-err.js b/test/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..6ec536b76c067bffe9e62ec09ef84e54e97e7873 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-step-err.case +// - src/dstr-binding/error/for-await-of-async-func-var.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: 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). +---*/ +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + throw new Test262Error(); + } + }; +}; + +async function fn() { + for await (var [x] of [g]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-iter-val-err.js b/test/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000000000000000000000000000000000..e9ffc53df2d87068615a62d8befc5ca7bec50d8c --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-err.case +// - src/dstr-binding/error/for-await-of-async-func-var.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: 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). +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +async function fn() { + for await (var [x] of [g]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-obj-val-null.js b/test/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000000000000000000000000000000000..441e5083d3d336dea8bcfcc1abfc98542502b869 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-null.case +// - src/dstr-binding/error/for-await-of-async-func-var.template +/*--- +description: Nested object destructuring with a null 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 ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: 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 : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + +async function fn() { + for await (var [{ x }] of [[null]]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-obj-val-undef.js b/test/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000000000000000000000000000000000..f0c5f2a395d8a4ff26daebf061e1b77c6921bd50 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-undef.case +// - src/dstr-binding/error/for-await-of-async-func-var.template +/*--- +description: Nested object destructuring with a value of `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 ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: 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 : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + +async function fn() { + for await (var [{ x }] of [[]]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elision-step-err.js b/test/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..e479c083047097d3ca9fcfbc078dfe1f5dc8828e --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elision-step-err.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/for-await-of-async-func-var.template +/*--- +description: Elision advances iterator and forwards abrupt completions (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 ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: 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). + +---*/ +var following = 0; +var iter =function* () { + throw new Test262Error(); + following += 1; +}(); + +async function fn() { + for await (var [,] of [iter]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-id-elision-next-err.js b/test/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000000000000000000000000000000000..11d946d86b5d0bf00d2decb0c6413a50fcb9e477 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision-next-err.case +// - src/dstr-binding/error/for-await-of-async-func-var.template +/*--- +description: Rest element following elision elements (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 ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: 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 iter = (function*() { throw new Test262Error(); })(); + +async function fn() { + for await (var [, ...x] of [iter]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-id-iter-step-err.js b/test/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..0505025f6376e297da1cdeee30dab108bbcbbd33 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case +// - src/dstr-binding/error/for-await-of-async-func-var.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (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 ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: 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, + a. If iteratorRecord.[[done]] is false, + i. Let next be IteratorStep(iteratorRecord.[[iterator]]). + ii. If next is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(next). + +---*/ +var first = 0; +var second = 0; +var iter = function*() { + first += 1; + throw new Test262Error(); + second += 1; +}(); + +async function fn() { + for await (var [...x] of [iter]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + +iter.next(); +assert.sameValue(first, 1); +assert.sameValue(second, 0, 'Iterator is closed following abrupt completion.'); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-id-iter-val-err.js b/test/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000000000000000000000000000000000..db39511b8a6753d6ba5f52c8af11dccbd879fc8f --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-val-err.case +// - src/dstr-binding/error/for-await-of-async-func-var.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (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 ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: 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, + [...] + c. Let nextValue be IteratorValue(next). + d. If nextValue is an abrupt completion, set iteratorRecord.[[done]] to + true. + e. ReturnIfAbrupt(nextValue). + +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +async function fn() { + for await (var [...x] of [iter]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-obj-init-null.js b/test/language/statements/for-await-of/async-func-dstr-var-obj-init-null.js new file mode 100644 index 0000000000000000000000000000000000000000..09d1a4ecce15636bd11785e8ae15937f5c7d773b --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-obj-init-null.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/for-await-of-async-func-var.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is 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). +---*/ + +async function fn() { + for await (var {} of [null]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-obj-init-undefined.js b/test/language/statements/for-await-of/async-func-dstr-var-obj-init-undefined.js new file mode 100644 index 0000000000000000000000000000000000000000..c088bb341c55555469f112fa368fd2c4bf9a17da --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-obj-init-undefined.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/for-await-of-async-func-var.template +/*--- +description: Value specifed for object binding pattern must be object coercible (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 ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is 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). +---*/ + +async function fn() { + for await (var {} of [undefined]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-id-get-value-err.js b/test/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000000000000000000000000000000000..5c5902f2443ab0b2552f7e852f744310ec8c6d1b --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-id-get-value-err.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-get-value-err.case +// - src/dstr-binding/error/for-await-of-async-func-var.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: 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 + + [...] + 4. Let v be GetV(value, propertyName). + 5. ReturnIfAbrupt(v). +---*/ +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + +async function fn() { + for await (var { poisoned } of [poisonedProperty]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-id-init-throws.js b/test/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..4b220333edfa9065d8a327e55f323920839457e6 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-id-init-throws.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/for-await-of-async-func-var.template +/*--- +description: Error thrown when evaluating the 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 ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: 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 + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + +async function fn() { + for await (var { x = thrower() } of [{}]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-id-init-unresolvable.js b/test/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..291a8cc4da1fcbf708bda2da374e0a871383745b --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/for-await-of-async-func-var.template +/*--- +description: Destructuring initializer is an unresolvable reference (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: 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 + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +async function fn() { + for await (var { x = unresolvableReference } of [{}]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, ReferenceError)) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-list-err.js b/test/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-list-err.js new file mode 100644 index 0000000000000000000000000000000000000000..bcf36faf02c4f08e107412d8f0d0e6448cda54d3 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-list-err.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/for-await-of-async-func-var.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: 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 + + BindingPropertyList : BindingPropertyList , BindingProperty + + 1. Let status be the result of performing BindingInitialization for + BindingPropertyList using value and environment as arguments. + 2. ReturnIfAbrupt(status). +---*/ +var initCount = 0; +function thrower() { + throw new Test262Error(); +} + +async function fn() { + for await (var { a, b = thrower(), c = ++initCount } of [{}]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + +assert.sameValue(initCount, 0); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-ary-value-null.js b/test/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000000000000000000000000000000000..93646baf3d65f7cbd949778b706cf80e5a61295e --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-value-null.case +// - src/dstr-binding/error/for-await-of-async-func-var.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` 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 ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: 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. +---*/ + +async function fn() { + for await (var { w: [x, y, z] = [4, 5, 6] } of [{ w: null }]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-eval-err.js b/test/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000000000000000000000000000000000..d680fe914d8985d2f5269b1640247d950fa9456e --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-eval-err.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/for-await-of-async-func-var.template +/*--- +description: Evaluation of property name returns an abrupt completion (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: 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 + + BindingProperty : PropertyName : BindingElement + + 1. Let P be the result of evaluating PropertyName + 2. ReturnIfAbrupt(P). +---*/ +function thrower() { + throw new Test262Error(); +} + +async function fn() { + for await (var { [thrower()]: x } of [{}]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-id-get-value-err.js b/test/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000000000000000000000000000000000..e23a739d4061021d81367b9b633db3fe15c67769 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-get-value-err.case +// - src/dstr-binding/error/for-await-of-async-func-var.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: 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 + + 1. Let v be GetV(value, propertyName). + 2. ReturnIfAbrupt(v). +---*/ +var initEvalCount = 0; +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + +async function fn() { + for await (var { poisoned: x = ++initEvalCount } of [poisonedProperty]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + +assert.sameValue(initEvalCount, 0); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-id-init-throws.js b/test/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..8c7240cde4a0fa76483eb3892c8dffd157d9c5e9 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-throws.case +// - src/dstr-binding/error/for-await-of-async-func-var.template +/*--- +description: Error thrown when evaluating the 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 ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: 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 + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + +async function fn() { + for await (var { x: y = thrower() } of [{}]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-id-init-unresolvable.js b/test/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..a31720a485b9213f10b40542bc6d9d32fa92fdcf --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-unresolvable.case +// - src/dstr-binding/error/for-await-of-async-func-var.template +/*--- +description: Destructuring initializer is an unresolvable reference (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: 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 + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +async function fn() { + for await (var { x: y = unresolvableReference } of [{}]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, ReferenceError)) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-obj-value-null.js b/test/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000000000000000000000000000000000..6f90b6939592e96db15bb356940a20159b3e30d3 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-null.case +// - src/dstr-binding/error/for-await-of-async-func-var.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` 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 ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: 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. +---*/ + +async function fn() { + for await (var { w: { x, y, z } = { x: 4, y: 5, z: 6 } } of [{ w: null }]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-obj-value-undef.js b/test/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000000000000000000000000000000000..8c8036684bfac3a90954428b45459e9c4dcc85d6 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-undef.case +// - src/dstr-binding/error/for-await-of-async-func-var.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` 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 ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: 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. +---*/ + +async function fn() { + for await (var { w: { x, y, z } = undefined } of [{ }]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-ary-init-iter-get-err.js b/test/language/statements/for-await-of/async-gen-dstr-const-ary-init-iter-get-err.js new file mode 100644 index 0000000000000000000000000000000000000000..1862861721f1f29e9e04262929db3708ebb02732 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-ary-init-iter-get-err.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/for-await-of-async-gen-const.template +/*--- +description: Abrupt completion returned by GetIterator (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 + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). + +---*/ +var iter = {}; +iter[Symbol.iterator] = function() { + throw new Test262Error(); +}; + +async function * gen() { + for await (const [x] of [iter]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-ary-val-null.js b/test/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000000000000000000000000000000000..a3a90b88fa67fa7c11bfe6761f558a7a374a34fc --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-val-null.case +// - src/dstr-binding/error/for-await-of-async-gen-const.template +/*--- +description: Nested array destructuring with a null 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 + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). +---*/ + +async function * gen() { + for await (const [[x]] of [[null]]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-init-throws.js b/test/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..8c0e96fba64f03c00c6481aa9b192eb7d43d594e --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-throws.case +// - src/dstr-binding/error/for-await-of-async-gen-const.template +/*--- +description: Destructuring initializer returns an abrupt completion (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: 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). +---*/ + +async function * gen() { + for await (const [x = (function() { throw new Test262Error(); })()] of [[undefined]]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-init-unresolvable.js b/test/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..a2d02f2c1696a2c027904a37dea5abf6f18b3f0b --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-unresolvable.case +// - src/dstr-binding/error/for-await-of-async-gen-const.template +/*--- +description: Destructuring initializer is an unresolvable reference (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: 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). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +async function * gen() { + for await (const [ x = unresolvableReference ] of [[]]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, ReferenceError)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-iter-step-err.js b/test/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..eb45be31ce41c232d60da3328905f2e189bf252d --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-step-err.case +// - src/dstr-binding/error/for-await-of-async-gen-const.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: 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). +---*/ +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + throw new Test262Error(); + } + }; +}; + +async function * gen() { + for await (const [x] of [g]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-iter-val-err.js b/test/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000000000000000000000000000000000..f22a8b721e6da4f75a1ee3d39857d7fbc3e4b212 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-err.case +// - src/dstr-binding/error/for-await-of-async-gen-const.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: 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). +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +async function * gen() { + for await (const [x] of [g]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-obj-val-null.js b/test/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000000000000000000000000000000000..72157c912bf1719d5c5b597cfa15ba5f4e03d872 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-null.case +// - src/dstr-binding/error/for-await-of-async-gen-const.template +/*--- +description: Nested object destructuring with a null 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 + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + +async function * gen() { + for await (const [{ x }] of [[null]]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-obj-val-undef.js b/test/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000000000000000000000000000000000..60ea181ceed0b34c824abc0eada31afc6a1d8a00 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-undef.case +// - src/dstr-binding/error/for-await-of-async-gen-const.template +/*--- +description: Nested object destructuring with a value of `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 + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + +async function * gen() { + for await (const [{ x }] of [[]]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elision-step-err.js b/test/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..d4704ce5ec9103b46406762c553f8f65f81b300b --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elision-step-err.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/for-await-of-async-gen-const.template +/*--- +description: Elision advances iterator and forwards abrupt completions (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). + +---*/ +var following = 0; +var iter =function* () { + throw new Test262Error(); + following += 1; +}(); + +async function * gen() { + for await (const [,] of [iter]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-id-elision-next-err.js b/test/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000000000000000000000000000000000..58ffcd6f641a70c4726ec79a80f97331cc6f45ae --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision-next-err.case +// - src/dstr-binding/error/for-await-of-async-gen-const.template +/*--- +description: Rest element following elision elements (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 : [ 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 iter = (function*() { throw new Test262Error(); })(); + +async function * gen() { + for await (const [, ...x] of [iter]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-id-iter-step-err.js b/test/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..57dd0e59cdb86678e9e00802fe99c4633f8aab36 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case +// - src/dstr-binding/error/for-await-of-async-gen-const.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (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 : ... 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, + a. If iteratorRecord.[[done]] is false, + i. Let next be IteratorStep(iteratorRecord.[[iterator]]). + ii. If next is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(next). + +---*/ +var first = 0; +var second = 0; +var iter = function*() { + first += 1; + throw new Test262Error(); + second += 1; +}(); + +async function * gen() { + for await (const [...x] of [iter]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + + +iter.next(); +assert.sameValue(first, 1); +assert.sameValue(second, 0, 'Iterator is closed following abrupt completion.'); diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-id-iter-val-err.js b/test/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000000000000000000000000000000000..182e1242b13dd98835de6204655f5d74f74a94d1 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-val-err.case +// - src/dstr-binding/error/for-await-of-async-gen-const.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (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, + [...] + c. Let nextValue be IteratorValue(next). + d. If nextValue is an abrupt completion, set iteratorRecord.[[done]] to + true. + e. ReturnIfAbrupt(nextValue). + +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +async function * gen() { + for await (const [...x] of [iter]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-obj-init-null.js b/test/language/statements/for-await-of/async-gen-dstr-const-obj-init-null.js new file mode 100644 index 0000000000000000000000000000000000000000..f033632b8a15e91d6e81ef4aa6cf31195e45aa36 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-obj-init-null.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/for-await-of-async-gen-const.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is 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). +---*/ + +async function * gen() { + for await (const {} of [null]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-obj-init-undefined.js b/test/language/statements/for-await-of/async-gen-dstr-const-obj-init-undefined.js new file mode 100644 index 0000000000000000000000000000000000000000..122c83a14050f6ecf4716e38c8167ce7dbc73165 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-obj-init-undefined.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/for-await-of-async-gen-const.template +/*--- +description: Value specifed for object binding pattern must be object coercible (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. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +async function * gen() { + for await (const {} of [undefined]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-id-get-value-err.js b/test/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000000000000000000000000000000000..7453f3c16631ed38386c20337e2e5f0e3d81025d --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-id-get-value-err.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-get-value-err.case +// - src/dstr-binding/error/for-await-of-async-gen-const.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: 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 + + [...] + 4. Let v be GetV(value, propertyName). + 5. ReturnIfAbrupt(v). +---*/ +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + +async function * gen() { + for await (const { poisoned } of [poisonedProperty]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-id-init-throws.js b/test/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..3ddbba3de5464a896b2163a613fc9204f2431394 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-id-init-throws.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/for-await-of-async-gen-const.template +/*--- +description: Error thrown when evaluating the 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 + + [...] + 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). +---*/ +function thrower() { + throw new Test262Error(); +} + +async function * gen() { + for await (const { x = thrower() } of [{}]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-id-init-unresolvable.js b/test/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..e608f96f3902d1c82c80a646df3b91cc61350f87 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/for-await-of-async-gen-const.template +/*--- +description: Destructuring initializer is an unresolvable reference (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: 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 + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +async function * gen() { + for await (const { x = unresolvableReference } of [{}]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, ReferenceError)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-list-err.js b/test/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-list-err.js new file mode 100644 index 0000000000000000000000000000000000000000..c902df24b8809ad0c6c878201f71415e2a14a0d9 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-list-err.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/for-await-of-async-gen-const.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: 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 + + BindingPropertyList : BindingPropertyList , BindingProperty + + 1. Let status be the result of performing BindingInitialization for + BindingPropertyList using value and environment as arguments. + 2. ReturnIfAbrupt(status). +---*/ +var initCount = 0; +function thrower() { + throw new Test262Error(); +} + +async function * gen() { + for await (const { a, b = thrower(), c = ++initCount } of [{}]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + + +assert.sameValue(initCount, 0); diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-ary-value-null.js b/test/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000000000000000000000000000000000..08361ef67ad59d3f662e07a95dae026d557ee79a --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-value-null.case +// - src/dstr-binding/error/for-await-of-async-gen-const.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` 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.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. +---*/ + +async function * gen() { + for await (const { w: [x, y, z] = [4, 5, 6] } of [{ w: null }]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-eval-err.js b/test/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000000000000000000000000000000000..39e7585c8d7122e9448eb61ad662c7c87ac26a18 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-eval-err.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/for-await-of-async-gen-const.template +/*--- +description: Evaluation of property name returns an abrupt completion (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: 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 + + BindingProperty : PropertyName : BindingElement + + 1. Let P be the result of evaluating PropertyName + 2. ReturnIfAbrupt(P). +---*/ +function thrower() { + throw new Test262Error(); +} + +async function * gen() { + for await (const { [thrower()]: x } of [{}]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-id-get-value-err.js b/test/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000000000000000000000000000000000..ac75fdbaac1af875e6a69b3adcc625c9e353982e --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-get-value-err.case +// - src/dstr-binding/error/for-await-of-async-gen-const.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: 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 + + 1. Let v be GetV(value, propertyName). + 2. ReturnIfAbrupt(v). +---*/ +var initEvalCount = 0; +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + +async function * gen() { + for await (const { poisoned: x = ++initEvalCount } of [poisonedProperty]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + + +assert.sameValue(initEvalCount, 0); diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-id-init-throws.js b/test/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..ec2c87bd53994c6c5e73bdd41e6086caf000db6c --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-throws.case +// - src/dstr-binding/error/for-await-of-async-gen-const.template +/*--- +description: Error thrown when evaluating the 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 + + BindingElement : BindingPattern Initializeropt + + [...] + 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). +---*/ +function thrower() { + throw new Test262Error(); +} + +async function * gen() { + for await (const { x: y = thrower() } of [{}]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-id-init-unresolvable.js b/test/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..1e579b0266d5fff119cf5f0f2a3b39def79f61e7 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-unresolvable.case +// - src/dstr-binding/error/for-await-of-async-gen-const.template +/*--- +description: Destructuring initializer is an unresolvable reference (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: 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 + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +async function * gen() { + for await (const { x: y = unresolvableReference } of [{}]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, ReferenceError)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-obj-value-null.js b/test/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000000000000000000000000000000000..e1870cbe3d7670c0ca3208b2bea9d9f6a84608d6 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-null.case +// - src/dstr-binding/error/for-await-of-async-gen-const.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` 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.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. +---*/ + +async function * gen() { + for await (const { w: { x, y, z } = { x: 4, y: 5, z: 6 } } of [{ w: null }]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-obj-value-undef.js b/test/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000000000000000000000000000000000..db09efb8f6b249621c568f8413c45ae409abef26 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-undef.case +// - src/dstr-binding/error/for-await-of-async-gen-const.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` 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.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. +---*/ + +async function * gen() { + for await (const { w: { x, y, z } = undefined } of [{ }]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-ary-init-iter-get-err.js b/test/language/statements/for-await-of/async-gen-dstr-let-ary-init-iter-get-err.js new file mode 100644 index 0000000000000000000000000000000000000000..46741b80e08f0aeb5d051ff37e97c00df4019313 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-ary-init-iter-get-err.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/for-await-of-async-gen-let.template +/*--- +description: Abrupt completion returned by GetIterator (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 ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: 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 + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). + +---*/ +var iter = {}; +iter[Symbol.iterator] = function() { + throw new Test262Error(); +}; + +async function * gen() { + for await (let [x] of [iter]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-ary-val-null.js b/test/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000000000000000000000000000000000..8cb11d7d936f39128dda8dc4dc1efd78d503e5f8 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-val-null.case +// - src/dstr-binding/error/for-await-of-async-gen-let.template +/*--- +description: Nested array destructuring with a null 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 ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: 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 : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). +---*/ + +async function * gen() { + for await (let [[x]] of [[null]]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-init-throws.js b/test/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..d5cd68a9d6cd6b157a0bbe9aa26c13c323901b7c --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-throws.case +// - src/dstr-binding/error/for-await-of-async-gen-let.template +/*--- +description: Destructuring initializer returns an abrupt completion (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: 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). +---*/ + +async function * gen() { + for await (let [x = (function() { throw new Test262Error(); })()] of [[undefined]]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-init-unresolvable.js b/test/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..9c2d1f4e0c4ec6a0f347bd24b0aece95ec970820 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-unresolvable.case +// - src/dstr-binding/error/for-await-of-async-gen-let.template +/*--- +description: Destructuring initializer is an unresolvable reference (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: 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). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +async function * gen() { + for await (let [ x = unresolvableReference ] of [[]]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, ReferenceError)) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-iter-step-err.js b/test/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..1329aeb034608a4f2016014062cd230ec22f3fb0 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-step-err.case +// - src/dstr-binding/error/for-await-of-async-gen-let.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: 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). +---*/ +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + throw new Test262Error(); + } + }; +}; + +async function * gen() { + for await (let [x] of [g]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-iter-val-err.js b/test/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000000000000000000000000000000000..ac90a30a4f534c87d1a4d87d784b2bdf69ded503 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-err.case +// - src/dstr-binding/error/for-await-of-async-gen-let.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: 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). +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +async function * gen() { + for await (let [x] of [g]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-obj-val-null.js b/test/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000000000000000000000000000000000..01423ae1553c7bb362511f8981b127ad84173282 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-null.case +// - src/dstr-binding/error/for-await-of-async-gen-let.template +/*--- +description: Nested object destructuring with a null 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 ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: 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 : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + +async function * gen() { + for await (let [{ x }] of [[null]]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-obj-val-undef.js b/test/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000000000000000000000000000000000..6af6d06f5570252a7b3f0591e697069a72bfcd3c --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-undef.case +// - src/dstr-binding/error/for-await-of-async-gen-let.template +/*--- +description: Nested object destructuring with a value of `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 ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: 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 : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + +async function * gen() { + for await (let [{ x }] of [[]]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elision-step-err.js b/test/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..b5a858877c7524c11544f5e264a93cd503e6c521 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elision-step-err.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/for-await-of-async-gen-let.template +/*--- +description: Elision advances iterator and forwards abrupt completions (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 ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: 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). + +---*/ +var following = 0; +var iter =function* () { + throw new Test262Error(); + following += 1; +}(); + +async function * gen() { + for await (let [,] of [iter]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-id-elision-next-err.js b/test/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000000000000000000000000000000000..fba96bfa78acd9b4dc908da5b4c6c4abd3594807 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision-next-err.case +// - src/dstr-binding/error/for-await-of-async-gen-let.template +/*--- +description: Rest element following elision elements (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 ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: 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 iter = (function*() { throw new Test262Error(); })(); + +async function * gen() { + for await (let [, ...x] of [iter]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-id-iter-step-err.js b/test/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..cadf333daba6d109e010312451b605673eb10e1a --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case +// - src/dstr-binding/error/for-await-of-async-gen-let.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (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 ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: 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, + a. If iteratorRecord.[[done]] is false, + i. Let next be IteratorStep(iteratorRecord.[[iterator]]). + ii. If next is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(next). + +---*/ +var first = 0; +var second = 0; +var iter = function*() { + first += 1; + throw new Test262Error(); + second += 1; +}(); + +async function * gen() { + for await (let [...x] of [iter]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + +iter.next(); +assert.sameValue(first, 1); +assert.sameValue(second, 0, 'Iterator is closed following abrupt completion.'); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-id-iter-val-err.js b/test/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000000000000000000000000000000000..251a49afb769dba66e701dd97c088a647196fed5 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-val-err.case +// - src/dstr-binding/error/for-await-of-async-gen-let.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (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 ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: 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, + [...] + c. Let nextValue be IteratorValue(next). + d. If nextValue is an abrupt completion, set iteratorRecord.[[done]] to + true. + e. ReturnIfAbrupt(nextValue). + +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +async function * gen() { + for await (let [...x] of [iter]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-obj-init-null.js b/test/language/statements/for-await-of/async-gen-dstr-let-obj-init-null.js new file mode 100644 index 0000000000000000000000000000000000000000..4c1b77e1a782d488648e1e6115871618504279da --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-obj-init-null.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/for-await-of-async-gen-let.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is 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). +---*/ + +async function * gen() { + for await (let {} of [null]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-obj-init-undefined.js b/test/language/statements/for-await-of/async-gen-dstr-let-obj-init-undefined.js new file mode 100644 index 0000000000000000000000000000000000000000..31254fe61c83340fab76f6f176548af7add31927 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-obj-init-undefined.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/for-await-of-async-gen-let.template +/*--- +description: Value specifed for object binding pattern must be object coercible (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 ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is 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). +---*/ + +async function * gen() { + for await (let {} of [undefined]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-id-get-value-err.js b/test/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000000000000000000000000000000000..02e34625eb51666a1f64f8ab75939b315eea98ad --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-id-get-value-err.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-get-value-err.case +// - src/dstr-binding/error/for-await-of-async-gen-let.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: 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 + + [...] + 4. Let v be GetV(value, propertyName). + 5. ReturnIfAbrupt(v). +---*/ +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + +async function * gen() { + for await (let { poisoned } of [poisonedProperty]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-id-init-throws.js b/test/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..b769bf10321c6544dbbc06f74b650c2a36e3eb74 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-id-init-throws.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/for-await-of-async-gen-let.template +/*--- +description: Error thrown when evaluating the 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 ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: 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 + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + +async function * gen() { + for await (let { x = thrower() } of [{}]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-id-init-unresolvable.js b/test/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..6ef453222a77a498d4db53f0cc65e7f130e4f0c4 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/for-await-of-async-gen-let.template +/*--- +description: Destructuring initializer is an unresolvable reference (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: 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 + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +async function * gen() { + for await (let { x = unresolvableReference } of [{}]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, ReferenceError)) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-list-err.js b/test/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-list-err.js new file mode 100644 index 0000000000000000000000000000000000000000..c4fa1f25ae59de80ee819df18bcb6933c7888da6 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-list-err.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/for-await-of-async-gen-let.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: 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 + + BindingPropertyList : BindingPropertyList , BindingProperty + + 1. Let status be the result of performing BindingInitialization for + BindingPropertyList using value and environment as arguments. + 2. ReturnIfAbrupt(status). +---*/ +var initCount = 0; +function thrower() { + throw new Test262Error(); +} + +async function * gen() { + for await (let { a, b = thrower(), c = ++initCount } of [{}]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + +assert.sameValue(initCount, 0); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-ary-value-null.js b/test/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000000000000000000000000000000000..3c32db5539f5ae26d22f52566a7160dfe5dbbcbe --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-value-null.case +// - src/dstr-binding/error/for-await-of-async-gen-let.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` 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 ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: 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. +---*/ + +async function * gen() { + for await (let { w: [x, y, z] = [4, 5, 6] } of [{ w: null }]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-eval-err.js b/test/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000000000000000000000000000000000..3cf4177b6ad10547507e1d7565aa966b4f90a770 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-eval-err.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/for-await-of-async-gen-let.template +/*--- +description: Evaluation of property name returns an abrupt completion (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: 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 + + BindingProperty : PropertyName : BindingElement + + 1. Let P be the result of evaluating PropertyName + 2. ReturnIfAbrupt(P). +---*/ +function thrower() { + throw new Test262Error(); +} + +async function * gen() { + for await (let { [thrower()]: x } of [{}]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-id-get-value-err.js b/test/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000000000000000000000000000000000..1692345a6660975a0c697f5926a12780bcf30b94 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-get-value-err.case +// - src/dstr-binding/error/for-await-of-async-gen-let.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: 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 + + 1. Let v be GetV(value, propertyName). + 2. ReturnIfAbrupt(v). +---*/ +var initEvalCount = 0; +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + +async function * gen() { + for await (let { poisoned: x = ++initEvalCount } of [poisonedProperty]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + +assert.sameValue(initEvalCount, 0); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-id-init-throws.js b/test/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..3271a5dfa99bf6f43c6e6281905ac5dbbad86d57 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-throws.case +// - src/dstr-binding/error/for-await-of-async-gen-let.template +/*--- +description: Error thrown when evaluating the 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 ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: 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 + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + +async function * gen() { + for await (let { x: y = thrower() } of [{}]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-id-init-unresolvable.js b/test/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..e831ea42e6019699ab2754d024ab2c2d425ce266 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-unresolvable.case +// - src/dstr-binding/error/for-await-of-async-gen-let.template +/*--- +description: Destructuring initializer is an unresolvable reference (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: 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 + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +async function * gen() { + for await (let { x: y = unresolvableReference } of [{}]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, ReferenceError)) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-obj-value-null.js b/test/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000000000000000000000000000000000..e23a1bb9e978b20f371db54006bcd7ac9dacdc26 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-null.case +// - src/dstr-binding/error/for-await-of-async-gen-let.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` 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 ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: 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. +---*/ + +async function * gen() { + for await (let { w: { x, y, z } = { x: 4, y: 5, z: 6 } } of [{ w: null }]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-obj-value-undef.js b/test/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000000000000000000000000000000000..82e71ea931bb3f5c3d1e505c2cc8d124943a2887 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-undef.case +// - src/dstr-binding/error/for-await-of-async-gen-let.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` 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 ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: 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. +---*/ + +async function * gen() { + for await (let { w: { x, y, z } = undefined } of [{ }]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-ary-init-iter-get-err.js b/test/language/statements/for-await-of/async-gen-dstr-var-ary-init-iter-get-err.js new file mode 100644 index 0000000000000000000000000000000000000000..a74a3b5d965c2faf0d4033563635864340cc0816 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-ary-init-iter-get-err.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/for-await-of-async-gen-var.template +/*--- +description: Abrupt completion returned by GetIterator (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 + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). + +---*/ +var iter = {}; +iter[Symbol.iterator] = function() { + throw new Test262Error(); +}; + +async function * gen() { + for await (var [x] of [iter]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-ary-val-null.js b/test/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000000000000000000000000000000000..a8ab29bbccef99a2a29a914f4f04e9a1bad78ae9 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-val-null.case +// - src/dstr-binding/error/for-await-of-async-gen-var.template +/*--- +description: Nested array destructuring with a null 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 + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). +---*/ + +async function * gen() { + for await (var [[x]] of [[null]]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-init-throws.js b/test/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..267d3362e0997d72eb4b3827005d8121248cda99 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-throws.case +// - src/dstr-binding/error/for-await-of-async-gen-var.template +/*--- +description: Destructuring initializer returns an abrupt completion (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: 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). +---*/ + +async function * gen() { + for await (var [x = (function() { throw new Test262Error(); })()] of [[undefined]]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-init-unresolvable.js b/test/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..ac20681ef8a3326b08d2b0cd0bc25ffd3a4c1a19 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-unresolvable.case +// - src/dstr-binding/error/for-await-of-async-gen-var.template +/*--- +description: Destructuring initializer is an unresolvable reference (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: 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). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +async function * gen() { + for await (var [ x = unresolvableReference ] of [[]]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, ReferenceError)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-iter-step-err.js b/test/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..1a0c0ce0c2bc557e9db9714794426f6bdb55dfa2 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-step-err.case +// - src/dstr-binding/error/for-await-of-async-gen-var.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: 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). +---*/ +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + throw new Test262Error(); + } + }; +}; + +async function * gen() { + for await (var [x] of [g]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-iter-val-err.js b/test/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000000000000000000000000000000000..9d764066f41558a07a4a5c7e9fd432f4f07f5c14 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-err.case +// - src/dstr-binding/error/for-await-of-async-gen-var.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: 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). +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +async function * gen() { + for await (var [x] of [g]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-obj-val-null.js b/test/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000000000000000000000000000000000..7ca17a4126ff4a4245891cccf88bc3ba17772813 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-null.case +// - src/dstr-binding/error/for-await-of-async-gen-var.template +/*--- +description: Nested object destructuring with a null 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 + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + +async function * gen() { + for await (var [{ x }] of [[null]]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-obj-val-undef.js b/test/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000000000000000000000000000000000..a2ef24f31c7387386ffff558f9789ded7d146454 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-undef.case +// - src/dstr-binding/error/for-await-of-async-gen-var.template +/*--- +description: Nested object destructuring with a value of `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 + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + +async function * gen() { + for await (var [{ x }] of [[]]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elision-step-err.js b/test/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..27b0231dbef6996739029fc9522fdfe6ecfa70d9 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elision-step-err.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/for-await-of-async-gen-var.template +/*--- +description: Elision advances iterator and forwards abrupt completions (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). + +---*/ +var following = 0; +var iter =function* () { + throw new Test262Error(); + following += 1; +}(); + +async function * gen() { + for await (var [,] of [iter]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-id-elision-next-err.js b/test/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000000000000000000000000000000000..cde00838d2dedc54a0c9b152f6140e6c551f7bbf --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision-next-err.case +// - src/dstr-binding/error/for-await-of-async-gen-var.template +/*--- +description: Rest element following elision elements (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 : [ 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 iter = (function*() { throw new Test262Error(); })(); + +async function * gen() { + for await (var [, ...x] of [iter]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-id-iter-step-err.js b/test/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..63e8ed66d71413685f9ca2036af74989fbf40dc6 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case +// - src/dstr-binding/error/for-await-of-async-gen-var.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (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 : ... 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, + a. If iteratorRecord.[[done]] is false, + i. Let next be IteratorStep(iteratorRecord.[[iterator]]). + ii. If next is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(next). + +---*/ +var first = 0; +var second = 0; +var iter = function*() { + first += 1; + throw new Test262Error(); + second += 1; +}(); + +async function * gen() { + for await (var [...x] of [iter]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + + +iter.next(); +assert.sameValue(first, 1); +assert.sameValue(second, 0, 'Iterator is closed following abrupt completion.'); diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-id-iter-val-err.js b/test/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000000000000000000000000000000000..a68cc731283b270bf27097c279d9aa5bf988a69a --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-val-err.case +// - src/dstr-binding/error/for-await-of-async-gen-var.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (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, + [...] + c. Let nextValue be IteratorValue(next). + d. If nextValue is an abrupt completion, set iteratorRecord.[[done]] to + true. + e. ReturnIfAbrupt(nextValue). + +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +async function * gen() { + for await (var [...x] of [iter]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-obj-init-null.js b/test/language/statements/for-await-of/async-gen-dstr-var-obj-init-null.js new file mode 100644 index 0000000000000000000000000000000000000000..db7e73ba92a29eeebd7000515c52fa390f38bd48 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-obj-init-null.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/for-await-of-async-gen-var.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is 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). +---*/ + +async function * gen() { + for await (var {} of [null]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-obj-init-undefined.js b/test/language/statements/for-await-of/async-gen-dstr-var-obj-init-undefined.js new file mode 100644 index 0000000000000000000000000000000000000000..21b565b2bbdb70640be04b965815270d3cc0c063 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-obj-init-undefined.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/for-await-of-async-gen-var.template +/*--- +description: Value specifed for object binding pattern must be object coercible (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. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +async function * gen() { + for await (var {} of [undefined]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-id-get-value-err.js b/test/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000000000000000000000000000000000..20a44666812669e9460de2de6580ee21fcf866fc --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-id-get-value-err.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-get-value-err.case +// - src/dstr-binding/error/for-await-of-async-gen-var.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: 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 + + [...] + 4. Let v be GetV(value, propertyName). + 5. ReturnIfAbrupt(v). +---*/ +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + +async function * gen() { + for await (var { poisoned } of [poisonedProperty]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-id-init-throws.js b/test/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..b24aac79e7e66d34e71479764a88352b7b008126 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-id-init-throws.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/for-await-of-async-gen-var.template +/*--- +description: Error thrown when evaluating the 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 + + [...] + 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). +---*/ +function thrower() { + throw new Test262Error(); +} + +async function * gen() { + for await (var { x = thrower() } of [{}]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-id-init-unresolvable.js b/test/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..36c561c4d1f74ae8233f59613eb06d0a2efb7261 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/for-await-of-async-gen-var.template +/*--- +description: Destructuring initializer is an unresolvable reference (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: 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 + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +async function * gen() { + for await (var { x = unresolvableReference } of [{}]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, ReferenceError)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-list-err.js b/test/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-list-err.js new file mode 100644 index 0000000000000000000000000000000000000000..ce5ff77d4738e15348b25e3142b924c1eb54fe48 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-list-err.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/for-await-of-async-gen-var.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: 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 + + BindingPropertyList : BindingPropertyList , BindingProperty + + 1. Let status be the result of performing BindingInitialization for + BindingPropertyList using value and environment as arguments. + 2. ReturnIfAbrupt(status). +---*/ +var initCount = 0; +function thrower() { + throw new Test262Error(); +} + +async function * gen() { + for await (var { a, b = thrower(), c = ++initCount } of [{}]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + + +assert.sameValue(initCount, 0); diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-ary-value-null.js b/test/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000000000000000000000000000000000..be9556f0f8dd5bc799f08ff503c7b6f35913987e --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-value-null.case +// - src/dstr-binding/error/for-await-of-async-gen-var.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` 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.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. +---*/ + +async function * gen() { + for await (var { w: [x, y, z] = [4, 5, 6] } of [{ w: null }]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-eval-err.js b/test/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000000000000000000000000000000000..0f682cbaf59b35b61680fc41584ad2665eaa2adf --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-eval-err.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/for-await-of-async-gen-var.template +/*--- +description: Evaluation of property name returns an abrupt completion (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: 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 + + BindingProperty : PropertyName : BindingElement + + 1. Let P be the result of evaluating PropertyName + 2. ReturnIfAbrupt(P). +---*/ +function thrower() { + throw new Test262Error(); +} + +async function * gen() { + for await (var { [thrower()]: x } of [{}]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-id-get-value-err.js b/test/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000000000000000000000000000000000..496b7fb325682fef0268061032e16941c2aad0fe --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-get-value-err.case +// - src/dstr-binding/error/for-await-of-async-gen-var.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: 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 + + 1. Let v be GetV(value, propertyName). + 2. ReturnIfAbrupt(v). +---*/ +var initEvalCount = 0; +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + +async function * gen() { + for await (var { poisoned: x = ++initEvalCount } of [poisonedProperty]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + + +assert.sameValue(initEvalCount, 0); diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-id-init-throws.js b/test/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..a03dcad4f3995ff89e7b6501eadc642cdec9549a --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-throws.case +// - src/dstr-binding/error/for-await-of-async-gen-var.template +/*--- +description: Error thrown when evaluating the 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 + + BindingElement : BindingPattern Initializeropt + + [...] + 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). +---*/ +function thrower() { + throw new Test262Error(); +} + +async function * gen() { + for await (var { x: y = thrower() } of [{}]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-id-init-unresolvable.js b/test/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..2da010c1591c19ab5806ef6e692460dcef85d423 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-unresolvable.case +// - src/dstr-binding/error/for-await-of-async-gen-var.template +/*--- +description: Destructuring initializer is an unresolvable reference (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: 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 + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +async function * gen() { + for await (var { x: y = unresolvableReference } of [{}]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, ReferenceError)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-obj-value-null.js b/test/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000000000000000000000000000000000..17ad2d3f61f4b87e16ea9457f76037200ce822af --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-null.case +// - src/dstr-binding/error/for-await-of-async-gen-var.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` 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.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. +---*/ + +async function * gen() { + for await (var { w: { x, y, z } = { x: 4, y: 5, z: 6 } } of [{ w: null }]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-obj-value-undef.js b/test/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000000000000000000000000000000000..20a1a2213ee287f6746571e8ac7b939d13975d8f --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-undef.case +// - src/dstr-binding/error/for-await-of-async-gen-var.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` 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.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. +---*/ + +async function * gen() { + for await (var { w: { x, y, z } = undefined } of [{ }]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); +