diff options
Diffstat (limited to 'js/src/tests/test262/language/statements/async-generator/dstr')
188 files changed, 8324 insertions, 0 deletions
diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/ary-init-iter-close.js b/js/src/tests/test262/language/statements/async-generator/dstr/ary-init-iter-close.js new file mode 100644 index 0000000000..66717ee508 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/ary-init-iter-close.js @@ -0,0 +1,52 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-close.case +// - src/dstr-binding/default/async-gen-func-decl.template +/*--- +description: Iterator is closed when not exhausted by pattern evaluation (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: false }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + + +var callCount = 0; +async function* f([x]) { + assert.sameValue(doneCallCount, 1); + callCount = callCount + 1; +}; +f(iter).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/ary-init-iter-get-err-array-prototype.js b/js/src/tests/test262/language/statements/async-generator/dstr/ary-init-iter-get-err-array-prototype.js new file mode 100644 index 0000000000..1a9865bda0 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/ary-init-iter-get-err-array-prototype.js @@ -0,0 +1,46 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err-array-prototype.case +// - src/dstr-binding/error/async-gen-func-decl.template +/*--- +description: Abrupt completion returned by GetIterator (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [Symbol.iterator, async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iteratorRecord be ? GetIterator(value). + + GetIterator ( obj [ , hint [ , method ] ] ) + + [...] + 4. Let iterator be ? Call(method, obj). + + Call ( F, V [ , argumentsList ] ) + + [...] + 2. If IsCallable(F) is false, throw a TypeError exception. + +---*/ +delete Array.prototype[Symbol.iterator]; + + +async function* f([x, y, z]) { + +}; + +assert.throws(TypeError, function() { + f([1, 2, 3]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/ary-init-iter-get-err.js b/js/src/tests/test262/language/statements/async-generator/dstr/ary-init-iter-get-err.js new file mode 100644 index 0000000000..47760857b7 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/ary-init-iter-get-err.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/async-gen-func-decl.template +/*--- +description: Abrupt completion returned by GetIterator (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [Symbol.iterator, async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 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* f([x]) { + +}; + +assert.throws(Test262Error, function() { + f(iter); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/ary-init-iter-no-close.js b/js/src/tests/test262/language/statements/async-generator/dstr/ary-init-iter-no-close.js new file mode 100644 index 0000000000..f42a6ef574 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/ary-init-iter-no-close.js @@ -0,0 +1,52 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-no-close.case +// - src/dstr-binding/default/async-gen-func-decl.template +/*--- +description: Iterator is not closed when exhausted by pattern evaluation (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: true }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + + +var callCount = 0; +async function* f([x]) { + assert.sameValue(doneCallCount, 0); + callCount = callCount + 1; +}; +f(iter).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/ary-name-iter-val.js b/js/src/tests/test262/language/statements/async-generator/dstr/ary-name-iter-val.js new file mode 100644 index 0000000000..9dd28b5cbd --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/ary-name-iter-val.js @@ -0,0 +1,51 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-name-iter-val.case +// - src/dstr-binding/default/async-gen-func-decl.template +/*--- +description: SingleNameBinding with normal value iteration (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +async function* f([x, y, z]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; +}; +f([1, 2, 3]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-ary-elem-init.js b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-ary-elem-init.js new file mode 100644 index 0000000000..5eeaddad31 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-ary-elem-init.js @@ -0,0 +1,43 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-init.case +// - src/dstr-binding/default/async-gen-func-decl.template +/*--- +description: BindingElement with array binding pattern and initializer is used (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + + +var callCount = 0; +async function* f([[x, y, z] = [4, 5, 6]]) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + callCount = callCount + 1; +}; +f([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-ary-elem-iter.js b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-ary-elem-iter.js new file mode 100644 index 0000000000..cbbc764a7b --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-ary-elem-iter.js @@ -0,0 +1,44 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-iter.case +// - src/dstr-binding/default/async-gen-func-decl.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + + +var callCount = 0; +async function* f([[x, y, z] = [4, 5, 6]]) { + assert.sameValue(x, 7); + assert.sameValue(y, 8); + assert.sameValue(z, 9); + callCount = callCount + 1; +}; +f([[7, 8, 9]]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-ary-elision-init.js b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-ary-elision-init.js new file mode 100644 index 0000000000..723e86f68d --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-ary-elision-init.js @@ -0,0 +1,50 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case +// - src/dstr-binding/default/async-gen-func-decl.template +/*--- +description: BindingElement with array binding pattern and initializer is used (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + + +var callCount = 0; +async function* f([[,] = g()]) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; +}; +f([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-ary-elision-iter.js b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-ary-elision-iter.js new file mode 100644 index 0000000000..40495d162f --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-ary-elision-iter.js @@ -0,0 +1,47 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-iter.case +// - src/dstr-binding/default/async-gen-func-decl.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var callCount = 0; +function* g() { + callCount += 1; +}; + + +var callCount = 0; +async function* f([[,] = g()]) { + assert.sameValue(callCount, 0); + callCount = callCount + 1; +}; +f([[]]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-ary-empty-init.js b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-ary-empty-init.js new file mode 100644 index 0000000000..fbdc137fd1 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-ary-empty-init.js @@ -0,0 +1,46 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-init.case +// - src/dstr-binding/default/async-gen-func-decl.template +/*--- +description: BindingElement with array binding pattern and initializer is used (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var initCount = 0; +var iterCount = 0; +var iter = function*() { iterCount += 1; }(); + + +var callCount = 0; +async function* f([[] = function() { initCount += 1; return iter; }()]) { + assert.sameValue(initCount, 1); + assert.sameValue(iterCount, 0); + callCount = callCount + 1; +}; +f([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-ary-empty-iter.js b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-ary-empty-iter.js new file mode 100644 index 0000000000..51d5ea22a1 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-ary-empty-iter.js @@ -0,0 +1,43 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-iter.case +// - src/dstr-binding/default/async-gen-func-decl.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; + + +var callCount = 0; +async function* f([[] = function() { initCount += 1; }()]) { + assert.sameValue(initCount, 0); + callCount = callCount + 1; +}; +f([[23]]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-ary-rest-init.js b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-ary-rest-init.js new file mode 100644 index 0000000000..78f1782d92 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-ary-rest-init.js @@ -0,0 +1,47 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-init.case +// - src/dstr-binding/default/async-gen-func-decl.template +/*--- +description: BindingElement with array binding pattern and initializer is used (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; + + +var callCount = 0; +async function* f([[...x] = values]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + callCount = callCount + 1; +}; +f([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-ary-rest-iter.js b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-ary-rest-iter.js new file mode 100644 index 0000000000..9271decb43 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-ary-rest-iter.js @@ -0,0 +1,50 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-iter.case +// - src/dstr-binding/default/async-gen-func-decl.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; +var initCount = 0; + + +var callCount = 0; +async function* f([[...x] = function() { initCount += 1; }()]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + assert.sameValue(initCount, 0); + callCount = callCount + 1; +}; +f([values]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-ary-val-null.js b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000..d0ebed22f0 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-val-null.case +// - src/dstr-binding/error/async-gen-func-decl.template +/*--- +description: Nested array destructuring with a null value (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 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* f([[x]]) { + +}; + +assert.throws(TypeError, function() { + f([null]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-id-init-exhausted.js b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-id-init-exhausted.js new file mode 100644 index 0000000000..aaf0cfd4cd --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-id-init-exhausted.js @@ -0,0 +1,42 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-exhausted.case +// - src/dstr-binding/default/async-gen-func-decl.template +/*--- +description: Destructuring initializer with an exhausted iterator (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +async function* f([x = 23]) { + assert.sameValue(x, 23); + callCount = callCount + 1; +}; +f([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..41133d343f --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-id-init-fn-name-arrow.js @@ -0,0 +1,43 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-arrow.case +// - src/dstr-binding/default/async-gen-func-decl.template +/*--- +description: SingleNameBinding does assign name to arrow functions (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +async function* f([arrow = () => {}]) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; +}; +f([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-id-init-fn-name-class.js new file mode 100644 index 0000000000..361a54ca1e --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-id-init-fn-name-class.js @@ -0,0 +1,45 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-class.case +// - src/dstr-binding/default/async-gen-func-decl.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +async function* f([cls = class {}, xCls = class X {}, xCls2 = class { static name() {} }]) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + assert.notSameValue(xCls2.name, 'xCls2'); + callCount = callCount + 1; +}; +f([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-id-init-fn-name-cover.js new file mode 100644 index 0000000000..35ac762a96 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-id-init-fn-name-cover.js @@ -0,0 +1,44 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-cover.case +// - src/dstr-binding/default/async-gen-func-decl.template +/*--- +description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +async function* f([cover = (function () {}), xCover = (0, function() {})]) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; +}; +f([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-id-init-fn-name-fn.js new file mode 100644 index 0000000000..0553c068fe --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-id-init-fn-name-fn.js @@ -0,0 +1,44 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-fn.case +// - src/dstr-binding/default/async-gen-func-decl.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +async function* f([fn = function () {}, xFn = function x() {}]) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; +}; +f([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-id-init-fn-name-gen.js new file mode 100644 index 0000000000..c785c7d025 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-id-init-fn-name-gen.js @@ -0,0 +1,45 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-gen.case +// - src/dstr-binding/default/async-gen-func-decl.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). + +---*/ + + +var callCount = 0; +async function* f([gen = function* () {}, xGen = function* x() {}]) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; +}; +f([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-id-init-hole.js b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-id-init-hole.js new file mode 100644 index 0000000000..2e66084421 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-id-init-hole.js @@ -0,0 +1,38 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-hole.case +// - src/dstr-binding/default/async-gen-func-decl.template +/*--- +description: Destructuring initializer with a "hole" (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + SingleNameBinding : BindingIdentifier Initializeropt + [...] 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +async function* f([x = 23]) { + assert.sameValue(x, 23); + // another statement + callCount = callCount + 1; +}; +f([,]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-id-init-skipped.js b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-id-init-skipped.js new file mode 100644 index 0000000000..937670ce09 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-id-init-skipped.js @@ -0,0 +1,47 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-skipped.case +// - src/dstr-binding/default/async-gen-func-decl.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + + +var callCount = 0; +async function* f([w = counter(), x = counter(), y = counter(), z = counter()]) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; +}; +f([null, 0, false, '']).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-id-init-throws.js b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000..a47cab8a60 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-throws.case +// - src/dstr-binding/error/async-gen-func-decl.template +/*--- +description: Destructuring initializer returns an abrupt completion (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 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* f([x = (function() { throw new Test262Error(); })()]) { + +}; + +assert.throws(Test262Error, function() { + f([undefined]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-id-init-undef.js b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-id-init-undef.js new file mode 100644 index 0000000000..711fcfc10b --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-id-init-undef.js @@ -0,0 +1,41 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-undef.case +// - src/dstr-binding/default/async-gen-func-decl.template +/*--- +description: Destructuring initializer with an undefined value (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +async function* f([x = 23]) { + assert.sameValue(x, 23); + callCount = callCount + 1; +}; +f([undefined]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-id-init-unresolvable.js b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000..91a4c062fe --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,45 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-unresolvable.case +// - src/dstr-binding/error/async-gen-func-decl.template +/*--- +description: Destructuring initializer is an unresolvable reference (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 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* f([ x = unresolvableReference ]) { + +}; + +assert.throws(ReferenceError, function() { + f([]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-id-iter-complete.js b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-id-iter-complete.js new file mode 100644 index 0000000000..d1a11c6fac --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-id-iter-complete.js @@ -0,0 +1,45 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-complete.case +// - src/dstr-binding/default/async-gen-func-decl.template +/*--- +description: SingleNameBinding when value iteration completes (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +async function* f([x]) { + assert.sameValue(x, undefined); + callCount = callCount + 1; +}; +f([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-id-iter-done.js b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-id-iter-done.js new file mode 100644 index 0000000000..d4b4d4e018 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-id-iter-done.js @@ -0,0 +1,40 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-done.case +// - src/dstr-binding/default/async-gen-func-decl.template +/*--- +description: SingleNameBinding when value iteration was completed previously (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +async function* f([_, x]) { + assert.sameValue(x, undefined); + callCount = callCount + 1; +}; +f([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-id-iter-step-err.js b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000..f572a96d70 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-step-err.case +// - src/dstr-binding/error/async-gen-func-decl.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [Symbol.iterator, async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 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* f([x]) { + +}; + +assert.throws(Test262Error, function() { + f(g); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-id-iter-val-array-prototype.js b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-id-iter-val-array-prototype.js new file mode 100644 index 0000000000..38b3441861 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-id-iter-val-array-prototype.js @@ -0,0 +1,61 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-array-prototype.case +// - src/dstr-binding/default/async-gen-func-decl.template +/*--- +description: Array destructuring uses overriden Array.prototype[Symbol.iterator] (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [Symbol.iterator, generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer_opt + + 1. Let bindingId be StringValue of BindingIdentifier. + 2. Let lhs be ? ResolveBinding(bindingId, environment). + 3. If iteratorRecord.[[Done]] is false, then + a. Let next be IteratorStep(iteratorRecord). + 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). + [...] + 7. Return InitializeReferencedBinding(lhs, v). + +---*/ +Array.prototype[Symbol.iterator] = function* () { + if (this.length > 0) { + yield this[0]; + } + if (this.length > 1) { + yield this[1]; + } + if (this.length > 2) { + yield 42; + } +}; + + +var callCount = 0; +async function* f([x, y, z]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 42); + callCount = callCount + 1; +}; +f([1, 2, 3]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-id-iter-val-err.js b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000..178441885a --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-err.case +// - src/dstr-binding/error/async-gen-func-decl.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [Symbol.iterator, async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 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* f([x]) { + +}; + +assert.throws(Test262Error, function() { + f(g); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-id-iter-val.js b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-id-iter-val.js new file mode 100644 index 0000000000..5c49770c68 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-id-iter-val.js @@ -0,0 +1,51 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val.case +// - src/dstr-binding/default/async-gen-func-decl.template +/*--- +description: SingleNameBinding when value iteration was completed previously (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +async function* f([x, y, z]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; +}; +f([1, 2, 3]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-obj-id-init.js b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-obj-id-init.js new file mode 100644 index 0000000000..050ac6608e --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-obj-id-init.js @@ -0,0 +1,43 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id-init.case +// - src/dstr-binding/default/async-gen-func-decl.template +/*--- +description: BindingElement with object binding pattern and initializer is used (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + + +var callCount = 0; +async function* f([{ x, y, z } = { x: 44, y: 55, z: 66 }]) { + assert.sameValue(x, 44); + assert.sameValue(y, 55); + assert.sameValue(z, 66); + callCount = callCount + 1; +}; +f([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-obj-id.js b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-obj-id.js new file mode 100644 index 0000000000..5b956e129f --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-obj-id.js @@ -0,0 +1,43 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id.case +// - src/dstr-binding/default/async-gen-func-decl.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + + +var callCount = 0; +async function* f([{ x, y, z } = { x: 44, y: 55, z: 66 }]) { + assert.sameValue(x, 11); + assert.sameValue(y, 22); + assert.sameValue(z, 33); + callCount = callCount + 1; +}; +f([{ x: 11, y: 22, z: 33 }]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-obj-prop-id-init.js b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-obj-prop-id-init.js new file mode 100644 index 0000000000..1880fe720f --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-obj-prop-id-init.js @@ -0,0 +1,53 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id-init.case +// - src/dstr-binding/default/async-gen-func-decl.template +/*--- +description: BindingElement with object binding pattern and initializer is used (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + + +var callCount = 0; +async function* f([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }]) { + assert.sameValue(v, 444); + assert.sameValue(x, 555); + assert.sameValue(z, 666); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; +}; +f([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-obj-prop-id.js b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-obj-prop-id.js new file mode 100644 index 0000000000..46e8755d07 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-obj-prop-id.js @@ -0,0 +1,53 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id.case +// - src/dstr-binding/default/async-gen-func-decl.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + + +var callCount = 0; +async function* f([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }]) { + assert.sameValue(v, 777); + assert.sameValue(x, 888); + assert.sameValue(z, 999); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; +}; +f([{ u: 777, w: 888, y: 999 }]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-obj-val-null.js b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000..a70d7d5795 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-null.case +// - src/dstr-binding/error/async-gen-func-decl.template +/*--- +description: Nested object destructuring with a null value (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 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* f([{ x }]) { + +}; + +assert.throws(TypeError, function() { + f([null]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-obj-val-undef.js b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000..025274a7d6 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-undef.case +// - src/dstr-binding/error/async-gen-func-decl.template +/*--- +description: Nested object destructuring with a value of `undefined` (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 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* f([{ x }]) { + +}; + +assert.throws(TypeError, function() { + f([]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elision-exhausted.js b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elision-exhausted.js new file mode 100644 index 0000000000..b7f11d1ab4 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elision-exhausted.js @@ -0,0 +1,48 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-exhausted.case +// - src/dstr-binding/default/async-gen-func-decl.template +/*--- +description: Elision accepts exhausted iterator (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + [...] + 2. Return NormalCompletion(empty). + +---*/ +var iter = function*() {}(); +iter.next(); + + +var callCount = 0; +async function* f([,]) { + + callCount = callCount + 1; +}; +f(iter).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elision-step-err.js b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000..cf759e2f6f --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elision-step-err.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/async-gen-func-decl.template +/*--- +description: Elision advances iterator and forwards abrupt completions (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [generators, async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 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* f([,]) { + +}; + +assert.throws(Test262Error, function() { + f(iter); +}); + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elision.js b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elision.js new file mode 100644 index 0000000000..2571145e47 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-elision.js @@ -0,0 +1,57 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision.case +// - src/dstr-binding/default/async-gen-func-decl.template +/*--- +description: Elision advances iterator (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + + +var callCount = 0; +async function* f([,]) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; +}; +f(g()).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-empty.js b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-empty.js new file mode 100644 index 0000000000..db417ba5bf --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-empty.js @@ -0,0 +1,40 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-empty.case +// - src/dstr-binding/default/async-gen-func-decl.template +/*--- +description: No iteration occurs for an "empty" array binding pattern (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + + +var callCount = 0; +async function* f([]) { + assert.sameValue(iterations, 0); + callCount = callCount + 1; +}; +f(iter).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-rest-ary-elem.js b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-rest-ary-elem.js new file mode 100644 index 0000000000..1d1e9fd881 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-rest-ary-elem.js @@ -0,0 +1,64 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elem.case +// - src/dstr-binding/default/async-gen-func-decl.template +/*--- +description: Rest element containing an array BindingElementList pattern (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +async function* f([...[x, y, z]]) { + assert.sameValue(x, 3); + assert.sameValue(y, 4); + assert.sameValue(z, 5); + callCount = callCount + 1; +}; +f([3, 4, 5]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-rest-ary-elision.js b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-rest-ary-elision.js new file mode 100644 index 0000000000..e83247fdc5 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-rest-ary-elision.js @@ -0,0 +1,70 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elision.case +// - src/dstr-binding/default/async-gen-func-decl.template +/*--- +description: Rest element containing an elision (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + + +var callCount = 0; +async function* f([...[,]]) { + assert.sameValue(first, 1); + assert.sameValue(second, 1); + callCount = callCount + 1; +}; +f(g()).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-rest-ary-empty.js b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-rest-ary-empty.js new file mode 100644 index 0000000000..73693bd1bd --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-rest-ary-empty.js @@ -0,0 +1,53 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-empty.case +// - src/dstr-binding/default/async-gen-func-decl.template +/*--- +description: Rest element containing an "empty" array pattern (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + + +var callCount = 0; +async function* f([...[]]) { + assert.sameValue(iterations, 1); + callCount = callCount + 1; +}; +f(iter).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-rest-ary-rest.js b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-rest-ary-rest.js new file mode 100644 index 0000000000..d1a09db82f --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-rest-ary-rest.js @@ -0,0 +1,49 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-rest.case +// - src/dstr-binding/default/async-gen-func-decl.template +/*--- +description: Rest element containing a rest element (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +var values = [1, 2, 3]; + + +var callCount = 0; +async function* f([...[...x]]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + + callCount = callCount + 1; +}; +f(values).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-rest-id-direct.js b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-rest-id-direct.js new file mode 100644 index 0000000000..e12f4ca909 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-rest-id-direct.js @@ -0,0 +1,44 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-direct.case +// - src/dstr-binding/default/async-gen-func-decl.template +/*--- +description: Lone rest element (direct binding) (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +includes: [compareArray.js] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingIdentifier + + [...] + 2. Let A be ! ArrayCreate(0). + 3. Let n be 0. + 4. Repeat, + [...] + f. Perform ! CreateDataPropertyOrThrow(A, ! ToString(n), nextValue). + g. Set n to n + 1. + +---*/ + + +var callCount = 0; +async function* f([...x]) { + assert(Array.isArray(x)); + assert.compareArray(x, [1]); + callCount = callCount + 1; +}; +f([1]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-rest-id-elision-next-err.js b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000..17aef78e13 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision-next-err.case +// - src/dstr-binding/error/async-gen-func-decl.template +/*--- +description: Rest element following elision elements (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [generators, async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 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* f([, ...x]) { + +}; + +assert.throws(Test262Error, function() { + f(iter); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-rest-id-elision.js b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-rest-id-elision.js new file mode 100644 index 0000000000..e78db95d58 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-rest-id-elision.js @@ -0,0 +1,45 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision.case +// - src/dstr-binding/default/async-gen-func-decl.template +/*--- +description: Rest element following elision elements (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. +---*/ +var values = [1, 2, 3, 4, 5]; + + +var callCount = 0; +async function* f([ , , ...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 3); + assert.sameValue(x[1], 4); + assert.sameValue(x[2], 5); + assert.notSameValue(x, values); + callCount = callCount + 1; +}; +f(values).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-rest-id-exhausted.js b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-rest-id-exhausted.js new file mode 100644 index 0000000000..afbae9f5b7 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-rest-id-exhausted.js @@ -0,0 +1,41 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-exhausted.case +// - src/dstr-binding/default/async-gen-func-decl.template +/*--- +description: RestElement applied to an exhausted iterator (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + b. If iteratorRecord.[[done]] is true, then + i. If environment is undefined, return PutValue(lhs, A). + ii. Return InitializeReferencedBinding(lhs, A). + +---*/ + + +var callCount = 0; +async function* f([, , ...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 0); + callCount = callCount + 1; +}; +f([1, 2]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-rest-id-iter-step-err.js b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000..c8ea051d59 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case +// - src/dstr-binding/error/async-gen-func-decl.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [generators, async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 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* f([...x]) { + +}; + +assert.throws(Test262Error, function() { + f(iter); +}); + +iter.next(); +assert.sameValue(first, 1); +assert.sameValue(second, 0, 'Iterator is closed following abrupt completion.'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-rest-id-iter-val-err.js b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000..58b4e41cae --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-val-err.case +// - src/dstr-binding/error/async-gen-func-decl.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [Symbol.iterator, async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 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* f([...x]) { + +}; + +assert.throws(Test262Error, function() { + f(iter); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-rest-id.js b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-rest-id.js new file mode 100644 index 0000000000..c6841c4a97 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-rest-id.js @@ -0,0 +1,42 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id.case +// - src/dstr-binding/default/async-gen-func-decl.template +/*--- +description: Lone rest element (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat + [...] + f. Let status be CreateDataProperty(A, ToString (n), nextValue). + [...] +---*/ +var values = [1, 2, 3]; + + +var callCount = 0; +async function* f([...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + callCount = callCount + 1; +}; +f(values).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-rest-init-ary.js b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-rest-init-ary.js new file mode 100644 index 0000000000..bb9b3db04e --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-rest-init-ary.js @@ -0,0 +1,39 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-ary.case +// - src/dstr-binding/default/async-gen-func-decl.template +/*--- +description: Rest element (nested array pattern) does not support initializer (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + + +var callCount = 0; +async function* f([...[ x ] = []]) { + + callCount = callCount + 1; +}; +f([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-rest-init-id.js b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-rest-init-id.js new file mode 100644 index 0000000000..ff6045f1af --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-rest-init-id.js @@ -0,0 +1,39 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-id.case +// - src/dstr-binding/default/async-gen-func-decl.template +/*--- +description: Rest element (identifier) does not support initializer (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + + +var callCount = 0; +async function* f([...x = []]) { + + callCount = callCount + 1; +}; +f([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-rest-init-obj.js b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-rest-init-obj.js new file mode 100644 index 0000000000..613a299c64 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-rest-init-obj.js @@ -0,0 +1,39 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-obj.case +// - src/dstr-binding/default/async-gen-func-decl.template +/*--- +description: Rest element (nested object pattern) does not support initializer (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + + +var callCount = 0; +async function* f([...{ x } = []]) { + + callCount = callCount + 1; +}; +f([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-rest-not-final-ary.js b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-rest-not-final-ary.js new file mode 100644 index 0000000000..5f7c9ee7e0 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-rest-not-final-ary.js @@ -0,0 +1,39 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-ary.case +// - src/dstr-binding/default/async-gen-func-decl.template +/*--- +description: Rest element (array binding pattern) may not be followed by any element (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + + +var callCount = 0; +async function* f([...[x], y]) { + + callCount = callCount + 1; +}; +f([1, 2, 3]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-rest-not-final-id.js b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-rest-not-final-id.js new file mode 100644 index 0000000000..e05edefa89 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-rest-not-final-id.js @@ -0,0 +1,39 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-id.case +// - src/dstr-binding/default/async-gen-func-decl.template +/*--- +description: Rest element (identifier) may not be followed by any element (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + + +var callCount = 0; +async function* f([...x, y]) { + + callCount = callCount + 1; +}; +f([1, 2, 3]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-rest-not-final-obj.js b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-rest-not-final-obj.js new file mode 100644 index 0000000000..33c334013c --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-rest-not-final-obj.js @@ -0,0 +1,39 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-obj.case +// - src/dstr-binding/default/async-gen-func-decl.template +/*--- +description: Rest element (object binding pattern) may not be followed by any element (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + + +var callCount = 0; +async function* f([...{ x }, y]) { + + callCount = callCount + 1; +}; +f([1, 2, 3]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-rest-obj-id.js b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-rest-obj-id.js new file mode 100644 index 0000000000..29a9d3265b --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-rest-obj-id.js @@ -0,0 +1,42 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-id.case +// - src/dstr-binding/default/async-gen-func-decl.template +/*--- +description: Rest element containing an object binding pattern (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + + +var callCount = 0; +async function* f([...{ length }]) { + assert.sameValue(length, 3); + callCount = callCount + 1; +}; +f([1, 2, 3]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-rest-obj-prop-id.js b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-rest-obj-prop-id.js new file mode 100644 index 0000000000..684eb38b2f --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/ary-ptrn-rest-obj-prop-id.js @@ -0,0 +1,49 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-prop-id.case +// - src/dstr-binding/default/async-gen-func-decl.template +/*--- +description: Rest element containing an object binding pattern (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +let length = "outer"; + + +var callCount = 0; +async function* f([...{ 0: v, 1: w, 2: x, 3: y, length: z }]) { + assert.sameValue(v, 7); + assert.sameValue(w, 8); + assert.sameValue(x, 9); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + assert.sameValue(length, "outer", "the length prop is not set as a binding name"); + callCount = callCount + 1; +}; +f([7, 8, 9]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/browser.js b/js/src/tests/test262/language/statements/async-generator/dstr/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/browser.js diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-init-iter-close.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-init-iter-close.js new file mode 100644 index 0000000000..6414b85cc5 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-init-iter-close.js @@ -0,0 +1,52 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-close.case +// - src/dstr-binding/default/async-gen-func-decl-dflt.template +/*--- +description: Iterator is closed when not exhausted by pattern evaluation (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: false }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + + +var callCount = 0; +async function* f([x] = iter) { + assert.sameValue(doneCallCount, 1); + callCount = callCount + 1; +}; +f().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-init-iter-get-err-array-prototype.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-init-iter-get-err-array-prototype.js new file mode 100644 index 0000000000..1a56240ee1 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-init-iter-get-err-array-prototype.js @@ -0,0 +1,46 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err-array-prototype.case +// - src/dstr-binding/error/async-gen-func-decl-dflt.template +/*--- +description: Abrupt completion returned by GetIterator (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [Symbol.iterator, async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iteratorRecord be ? GetIterator(value). + + GetIterator ( obj [ , hint [ , method ] ] ) + + [...] + 4. Let iterator be ? Call(method, obj). + + Call ( F, V [ , argumentsList ] ) + + [...] + 2. If IsCallable(F) is false, throw a TypeError exception. + +---*/ +delete Array.prototype[Symbol.iterator]; + + +async function* f([x, y, z] = [1, 2, 3]) { + +}; + +assert.throws(TypeError, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-init-iter-get-err.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-init-iter-get-err.js new file mode 100644 index 0000000000..de44a6cc57 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-init-iter-get-err.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/async-gen-func-decl-dflt.template +/*--- +description: Abrupt completion returned by GetIterator (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [Symbol.iterator, async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 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* f([x] = iter) { + +}; + +assert.throws(Test262Error, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-init-iter-no-close.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-init-iter-no-close.js new file mode 100644 index 0000000000..e8e41b61f0 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-init-iter-no-close.js @@ -0,0 +1,52 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-no-close.case +// - src/dstr-binding/default/async-gen-func-decl-dflt.template +/*--- +description: Iterator is not closed when exhausted by pattern evaluation (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: true }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + + +var callCount = 0; +async function* f([x] = iter) { + assert.sameValue(doneCallCount, 0); + callCount = callCount + 1; +}; +f().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-name-iter-val.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-name-iter-val.js new file mode 100644 index 0000000000..8465a02be4 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-name-iter-val.js @@ -0,0 +1,51 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-name-iter-val.case +// - src/dstr-binding/default/async-gen-func-decl-dflt.template +/*--- +description: SingleNameBinding with normal value iteration (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +async function* f([x, y, z] = [1, 2, 3]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; +}; +f().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-ary-elem-init.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-ary-elem-init.js new file mode 100644 index 0000000000..b1767c07f9 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-ary-elem-init.js @@ -0,0 +1,43 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-init.case +// - src/dstr-binding/default/async-gen-func-decl-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + + +var callCount = 0; +async function* f([[x, y, z] = [4, 5, 6]] = []) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + callCount = callCount + 1; +}; +f().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-ary-elem-iter.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-ary-elem-iter.js new file mode 100644 index 0000000000..23964a3413 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-ary-elem-iter.js @@ -0,0 +1,44 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-iter.case +// - src/dstr-binding/default/async-gen-func-decl-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + + +var callCount = 0; +async function* f([[x, y, z] = [4, 5, 6]] = [[7, 8, 9]]) { + assert.sameValue(x, 7); + assert.sameValue(y, 8); + assert.sameValue(z, 9); + callCount = callCount + 1; +}; +f().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-ary-elision-init.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-ary-elision-init.js new file mode 100644 index 0000000000..0f5d51e217 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-ary-elision-init.js @@ -0,0 +1,50 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case +// - src/dstr-binding/default/async-gen-func-decl-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + + +var callCount = 0; +async function* f([[,] = g()] = []) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; +}; +f().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-ary-elision-iter.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-ary-elision-iter.js new file mode 100644 index 0000000000..dc8b97e069 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-ary-elision-iter.js @@ -0,0 +1,47 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-iter.case +// - src/dstr-binding/default/async-gen-func-decl-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var callCount = 0; +function* g() { + callCount += 1; +}; + + +var callCount = 0; +async function* f([[,] = g()] = [[]]) { + assert.sameValue(callCount, 0); + callCount = callCount + 1; +}; +f().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-ary-empty-init.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-ary-empty-init.js new file mode 100644 index 0000000000..c86116e893 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-ary-empty-init.js @@ -0,0 +1,46 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-init.case +// - src/dstr-binding/default/async-gen-func-decl-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var initCount = 0; +var iterCount = 0; +var iter = function*() { iterCount += 1; }(); + + +var callCount = 0; +async function* f([[] = function() { initCount += 1; return iter; }()] = []) { + assert.sameValue(initCount, 1); + assert.sameValue(iterCount, 0); + callCount = callCount + 1; +}; +f().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-ary-empty-iter.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-ary-empty-iter.js new file mode 100644 index 0000000000..bd28dd3256 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-ary-empty-iter.js @@ -0,0 +1,43 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-iter.case +// - src/dstr-binding/default/async-gen-func-decl-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; + + +var callCount = 0; +async function* f([[] = function() { initCount += 1; }()] = [[23]]) { + assert.sameValue(initCount, 0); + callCount = callCount + 1; +}; +f().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-ary-rest-init.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-ary-rest-init.js new file mode 100644 index 0000000000..52d1b56404 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-ary-rest-init.js @@ -0,0 +1,47 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-init.case +// - src/dstr-binding/default/async-gen-func-decl-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; + + +var callCount = 0; +async function* f([[...x] = values] = []) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + callCount = callCount + 1; +}; +f().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-ary-rest-iter.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-ary-rest-iter.js new file mode 100644 index 0000000000..87d6e440ae --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-ary-rest-iter.js @@ -0,0 +1,50 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-iter.case +// - src/dstr-binding/default/async-gen-func-decl-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; +var initCount = 0; + + +var callCount = 0; +async function* f([[...x] = function() { initCount += 1; }()] = [values]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + assert.sameValue(initCount, 0); + callCount = callCount + 1; +}; +f().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-ary-val-null.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000..07776a80c7 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-val-null.case +// - src/dstr-binding/error/async-gen-func-decl-dflt.template +/*--- +description: Nested array destructuring with a null value (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 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* f([[x]] = [null]) { + +}; + +assert.throws(TypeError, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-id-init-exhausted.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-id-init-exhausted.js new file mode 100644 index 0000000000..cd7012022b --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-id-init-exhausted.js @@ -0,0 +1,42 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-exhausted.case +// - src/dstr-binding/default/async-gen-func-decl-dflt.template +/*--- +description: Destructuring initializer with an exhausted iterator (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +async function* f([x = 23] = []) { + assert.sameValue(x, 23); + callCount = callCount + 1; +}; +f().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..5618b6127c --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-id-init-fn-name-arrow.js @@ -0,0 +1,43 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-arrow.case +// - src/dstr-binding/default/async-gen-func-decl-dflt.template +/*--- +description: SingleNameBinding does assign name to arrow functions (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +async function* f([arrow = () => {}] = []) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; +}; +f().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-id-init-fn-name-class.js new file mode 100644 index 0000000000..f8af995ee3 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-id-init-fn-name-class.js @@ -0,0 +1,45 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-class.case +// - src/dstr-binding/default/async-gen-func-decl-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +async function* f([cls = class {}, xCls = class X {}, xCls2 = class { static name() {} }] = []) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + assert.notSameValue(xCls2.name, 'xCls2'); + callCount = callCount + 1; +}; +f().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-id-init-fn-name-cover.js new file mode 100644 index 0000000000..a7a2ac2817 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-id-init-fn-name-cover.js @@ -0,0 +1,44 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-cover.case +// - src/dstr-binding/default/async-gen-func-decl-dflt.template +/*--- +description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +async function* f([cover = (function () {}), xCover = (0, function() {})] = []) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; +}; +f().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-id-init-fn-name-fn.js new file mode 100644 index 0000000000..29cb41fcc3 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-id-init-fn-name-fn.js @@ -0,0 +1,44 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-fn.case +// - src/dstr-binding/default/async-gen-func-decl-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +async function* f([fn = function () {}, xFn = function x() {}] = []) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; +}; +f().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-id-init-fn-name-gen.js new file mode 100644 index 0000000000..9e06b9f8d5 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-id-init-fn-name-gen.js @@ -0,0 +1,45 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-gen.case +// - src/dstr-binding/default/async-gen-func-decl-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). + +---*/ + + +var callCount = 0; +async function* f([gen = function* () {}, xGen = function* x() {}] = []) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; +}; +f().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-id-init-hole.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-id-init-hole.js new file mode 100644 index 0000000000..06d9249510 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-id-init-hole.js @@ -0,0 +1,38 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-hole.case +// - src/dstr-binding/default/async-gen-func-decl-dflt.template +/*--- +description: Destructuring initializer with a "hole" (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + SingleNameBinding : BindingIdentifier Initializeropt + [...] 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +async function* f([x = 23] = [,]) { + assert.sameValue(x, 23); + // another statement + callCount = callCount + 1; +}; +f().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-id-init-skipped.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-id-init-skipped.js new file mode 100644 index 0000000000..4ac8a44b1d --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-id-init-skipped.js @@ -0,0 +1,47 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-skipped.case +// - src/dstr-binding/default/async-gen-func-decl-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + + +var callCount = 0; +async function* f([w = counter(), x = counter(), y = counter(), z = counter()] = [null, 0, false, '']) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; +}; +f().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-id-init-throws.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000..21664b01a2 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-throws.case +// - src/dstr-binding/error/async-gen-func-decl-dflt.template +/*--- +description: Destructuring initializer returns an abrupt completion (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 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* f([x = (function() { throw new Test262Error(); })()] = [undefined]) { + +}; + +assert.throws(Test262Error, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-id-init-undef.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-id-init-undef.js new file mode 100644 index 0000000000..d65d474711 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-id-init-undef.js @@ -0,0 +1,41 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-undef.case +// - src/dstr-binding/default/async-gen-func-decl-dflt.template +/*--- +description: Destructuring initializer with an undefined value (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +async function* f([x = 23] = [undefined]) { + assert.sameValue(x, 23); + callCount = callCount + 1; +}; +f().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-id-init-unresolvable.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000..fafba0dda8 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,45 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-unresolvable.case +// - src/dstr-binding/error/async-gen-func-decl-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 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* f([ x = unresolvableReference ] = []) { + +}; + +assert.throws(ReferenceError, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-id-iter-complete.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-id-iter-complete.js new file mode 100644 index 0000000000..c1e0cdc1cb --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-id-iter-complete.js @@ -0,0 +1,45 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-complete.case +// - src/dstr-binding/default/async-gen-func-decl-dflt.template +/*--- +description: SingleNameBinding when value iteration completes (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +async function* f([x] = []) { + assert.sameValue(x, undefined); + callCount = callCount + 1; +}; +f().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-id-iter-done.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-id-iter-done.js new file mode 100644 index 0000000000..ac2460e888 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-id-iter-done.js @@ -0,0 +1,40 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-done.case +// - src/dstr-binding/default/async-gen-func-decl-dflt.template +/*--- +description: SingleNameBinding when value iteration was completed previously (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +async function* f([_, x] = []) { + assert.sameValue(x, undefined); + callCount = callCount + 1; +}; +f().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-id-iter-step-err.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000..8c48978994 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-step-err.case +// - src/dstr-binding/error/async-gen-func-decl-dflt.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [Symbol.iterator, async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 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* f([x] = g) { + +}; + +assert.throws(Test262Error, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-id-iter-val-array-prototype.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-id-iter-val-array-prototype.js new file mode 100644 index 0000000000..ea16359a78 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-id-iter-val-array-prototype.js @@ -0,0 +1,61 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-array-prototype.case +// - src/dstr-binding/default/async-gen-func-decl-dflt.template +/*--- +description: Array destructuring uses overriden Array.prototype[Symbol.iterator] (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [Symbol.iterator, generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer_opt + + 1. Let bindingId be StringValue of BindingIdentifier. + 2. Let lhs be ? ResolveBinding(bindingId, environment). + 3. If iteratorRecord.[[Done]] is false, then + a. Let next be IteratorStep(iteratorRecord). + 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). + [...] + 7. Return InitializeReferencedBinding(lhs, v). + +---*/ +Array.prototype[Symbol.iterator] = function* () { + if (this.length > 0) { + yield this[0]; + } + if (this.length > 1) { + yield this[1]; + } + if (this.length > 2) { + yield 42; + } +}; + + +var callCount = 0; +async function* f([x, y, z] = [1, 2, 3]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 42); + callCount = callCount + 1; +}; +f().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-id-iter-val-err.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000..b35c1aae02 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-err.case +// - src/dstr-binding/error/async-gen-func-decl-dflt.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [Symbol.iterator, async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 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* f([x] = g) { + +}; + +assert.throws(Test262Error, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-id-iter-val.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-id-iter-val.js new file mode 100644 index 0000000000..25876266b0 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-id-iter-val.js @@ -0,0 +1,51 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val.case +// - src/dstr-binding/default/async-gen-func-decl-dflt.template +/*--- +description: SingleNameBinding when value iteration was completed previously (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +async function* f([x, y, z] = [1, 2, 3]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; +}; +f().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-obj-id-init.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-obj-id-init.js new file mode 100644 index 0000000000..0b777e4c10 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-obj-id-init.js @@ -0,0 +1,43 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id-init.case +// - src/dstr-binding/default/async-gen-func-decl-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is used (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + + +var callCount = 0; +async function* f([{ x, y, z } = { x: 44, y: 55, z: 66 }] = []) { + assert.sameValue(x, 44); + assert.sameValue(y, 55); + assert.sameValue(z, 66); + callCount = callCount + 1; +}; +f().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-obj-id.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-obj-id.js new file mode 100644 index 0000000000..32510ad6ff --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-obj-id.js @@ -0,0 +1,43 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id.case +// - src/dstr-binding/default/async-gen-func-decl-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + + +var callCount = 0; +async function* f([{ x, y, z } = { x: 44, y: 55, z: 66 }] = [{ x: 11, y: 22, z: 33 }]) { + assert.sameValue(x, 11); + assert.sameValue(y, 22); + assert.sameValue(z, 33); + callCount = callCount + 1; +}; +f().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-obj-prop-id-init.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-obj-prop-id-init.js new file mode 100644 index 0000000000..5a8c4cf500 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-obj-prop-id-init.js @@ -0,0 +1,53 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id-init.case +// - src/dstr-binding/default/async-gen-func-decl-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is used (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + + +var callCount = 0; +async function* f([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] = []) { + assert.sameValue(v, 444); + assert.sameValue(x, 555); + assert.sameValue(z, 666); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; +}; +f().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-obj-prop-id.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-obj-prop-id.js new file mode 100644 index 0000000000..e1894c266d --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-obj-prop-id.js @@ -0,0 +1,53 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id.case +// - src/dstr-binding/default/async-gen-func-decl-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + + +var callCount = 0; +async function* f([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] = [{ u: 777, w: 888, y: 999 }]) { + assert.sameValue(v, 777); + assert.sameValue(x, 888); + assert.sameValue(z, 999); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; +}; +f().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-obj-val-null.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000..b1da8b1b5f --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-null.case +// - src/dstr-binding/error/async-gen-func-decl-dflt.template +/*--- +description: Nested object destructuring with a null value (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 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* f([{ x }] = [null]) { + +}; + +assert.throws(TypeError, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-obj-val-undef.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000..98f8e419ac --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-undef.case +// - src/dstr-binding/error/async-gen-func-decl-dflt.template +/*--- +description: Nested object destructuring with a value of `undefined` (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 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* f([{ x }] = []) { + +}; + +assert.throws(TypeError, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elision-exhausted.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elision-exhausted.js new file mode 100644 index 0000000000..36ee1dd508 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elision-exhausted.js @@ -0,0 +1,48 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-exhausted.case +// - src/dstr-binding/default/async-gen-func-decl-dflt.template +/*--- +description: Elision accepts exhausted iterator (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + [...] + 2. Return NormalCompletion(empty). + +---*/ +var iter = function*() {}(); +iter.next(); + + +var callCount = 0; +async function* f([,] = iter) { + + callCount = callCount + 1; +}; +f().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elision-step-err.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000..7961fd0631 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elision-step-err.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/async-gen-func-decl-dflt.template +/*--- +description: Elision advances iterator and forwards abrupt completions (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [generators, async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 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* f([,] = iter) { + +}; + +assert.throws(Test262Error, function() { + f(); +}); + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elision.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elision.js new file mode 100644 index 0000000000..d6b839cf5c --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-elision.js @@ -0,0 +1,57 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision.case +// - src/dstr-binding/default/async-gen-func-decl-dflt.template +/*--- +description: Elision advances iterator (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + + +var callCount = 0; +async function* f([,] = g()) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; +}; +f().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-empty.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-empty.js new file mode 100644 index 0000000000..8d415e85d6 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-empty.js @@ -0,0 +1,40 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-empty.case +// - src/dstr-binding/default/async-gen-func-decl-dflt.template +/*--- +description: No iteration occurs for an "empty" array binding pattern (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + + +var callCount = 0; +async function* f([] = iter) { + assert.sameValue(iterations, 0); + callCount = callCount + 1; +}; +f().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-rest-ary-elem.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-rest-ary-elem.js new file mode 100644 index 0000000000..d59f9184cf --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-rest-ary-elem.js @@ -0,0 +1,64 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elem.case +// - src/dstr-binding/default/async-gen-func-decl-dflt.template +/*--- +description: Rest element containing an array BindingElementList pattern (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +async function* f([...[x, y, z]] = [3, 4, 5]) { + assert.sameValue(x, 3); + assert.sameValue(y, 4); + assert.sameValue(z, 5); + callCount = callCount + 1; +}; +f().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-rest-ary-elision.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-rest-ary-elision.js new file mode 100644 index 0000000000..74ce17b637 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-rest-ary-elision.js @@ -0,0 +1,70 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elision.case +// - src/dstr-binding/default/async-gen-func-decl-dflt.template +/*--- +description: Rest element containing an elision (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + + +var callCount = 0; +async function* f([...[,]] = g()) { + assert.sameValue(first, 1); + assert.sameValue(second, 1); + callCount = callCount + 1; +}; +f().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-rest-ary-empty.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-rest-ary-empty.js new file mode 100644 index 0000000000..534fee7f9e --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-rest-ary-empty.js @@ -0,0 +1,53 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-empty.case +// - src/dstr-binding/default/async-gen-func-decl-dflt.template +/*--- +description: Rest element containing an "empty" array pattern (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + + +var callCount = 0; +async function* f([...[]] = iter) { + assert.sameValue(iterations, 1); + callCount = callCount + 1; +}; +f().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-rest-ary-rest.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-rest-ary-rest.js new file mode 100644 index 0000000000..97ef5cf592 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-rest-ary-rest.js @@ -0,0 +1,49 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-rest.case +// - src/dstr-binding/default/async-gen-func-decl-dflt.template +/*--- +description: Rest element containing a rest element (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +var values = [1, 2, 3]; + + +var callCount = 0; +async function* f([...[...x]] = values) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + + callCount = callCount + 1; +}; +f().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-rest-id-direct.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-rest-id-direct.js new file mode 100644 index 0000000000..20ab4e6e64 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-rest-id-direct.js @@ -0,0 +1,44 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-direct.case +// - src/dstr-binding/default/async-gen-func-decl-dflt.template +/*--- +description: Lone rest element (direct binding) (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +includes: [compareArray.js] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingIdentifier + + [...] + 2. Let A be ! ArrayCreate(0). + 3. Let n be 0. + 4. Repeat, + [...] + f. Perform ! CreateDataPropertyOrThrow(A, ! ToString(n), nextValue). + g. Set n to n + 1. + +---*/ + + +var callCount = 0; +async function* f([...x] = [1]) { + assert(Array.isArray(x)); + assert.compareArray(x, [1]); + callCount = callCount + 1; +}; +f().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-rest-id-elision-next-err.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000..3b681e70e2 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision-next-err.case +// - src/dstr-binding/error/async-gen-func-decl-dflt.template +/*--- +description: Rest element following elision elements (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [generators, async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 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* f([, ...x] = iter) { + +}; + +assert.throws(Test262Error, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-rest-id-elision.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-rest-id-elision.js new file mode 100644 index 0000000000..a3a71900f0 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-rest-id-elision.js @@ -0,0 +1,45 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision.case +// - src/dstr-binding/default/async-gen-func-decl-dflt.template +/*--- +description: Rest element following elision elements (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. +---*/ +var values = [1, 2, 3, 4, 5]; + + +var callCount = 0; +async function* f([ , , ...x] = values) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 3); + assert.sameValue(x[1], 4); + assert.sameValue(x[2], 5); + assert.notSameValue(x, values); + callCount = callCount + 1; +}; +f().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-rest-id-exhausted.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-rest-id-exhausted.js new file mode 100644 index 0000000000..0dd8596944 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-rest-id-exhausted.js @@ -0,0 +1,41 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-exhausted.case +// - src/dstr-binding/default/async-gen-func-decl-dflt.template +/*--- +description: RestElement applied to an exhausted iterator (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + b. If iteratorRecord.[[done]] is true, then + i. If environment is undefined, return PutValue(lhs, A). + ii. Return InitializeReferencedBinding(lhs, A). + +---*/ + + +var callCount = 0; +async function* f([, , ...x] = [1, 2]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 0); + callCount = callCount + 1; +}; +f().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-rest-id-iter-step-err.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000..77cd5280ed --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case +// - src/dstr-binding/error/async-gen-func-decl-dflt.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [generators, async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 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* f([...x] = iter) { + +}; + +assert.throws(Test262Error, function() { + f(); +}); + +iter.next(); +assert.sameValue(first, 1); +assert.sameValue(second, 0, 'Iterator is closed following abrupt completion.'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-rest-id-iter-val-err.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000..daea98a488 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-val-err.case +// - src/dstr-binding/error/async-gen-func-decl-dflt.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [Symbol.iterator, async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 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* f([...x] = iter) { + +}; + +assert.throws(Test262Error, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-rest-id.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-rest-id.js new file mode 100644 index 0000000000..39b0da8701 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-rest-id.js @@ -0,0 +1,42 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id.case +// - src/dstr-binding/default/async-gen-func-decl-dflt.template +/*--- +description: Lone rest element (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat + [...] + f. Let status be CreateDataProperty(A, ToString (n), nextValue). + [...] +---*/ +var values = [1, 2, 3]; + + +var callCount = 0; +async function* f([...x] = values) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + callCount = callCount + 1; +}; +f().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-rest-init-ary.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-rest-init-ary.js new file mode 100644 index 0000000000..4ce335cf4e --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-rest-init-ary.js @@ -0,0 +1,39 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-ary.case +// - src/dstr-binding/default/async-gen-func-decl-dflt.template +/*--- +description: Rest element (nested array pattern) does not support initializer (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + + +var callCount = 0; +async function* f([...[ x ] = []] = []) { + + callCount = callCount + 1; +}; +f().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-rest-init-id.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-rest-init-id.js new file mode 100644 index 0000000000..9b4c9810e3 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-rest-init-id.js @@ -0,0 +1,39 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-id.case +// - src/dstr-binding/default/async-gen-func-decl-dflt.template +/*--- +description: Rest element (identifier) does not support initializer (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + + +var callCount = 0; +async function* f([...x = []] = []) { + + callCount = callCount + 1; +}; +f().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-rest-init-obj.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-rest-init-obj.js new file mode 100644 index 0000000000..215054fba8 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-rest-init-obj.js @@ -0,0 +1,39 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-obj.case +// - src/dstr-binding/default/async-gen-func-decl-dflt.template +/*--- +description: Rest element (nested object pattern) does not support initializer (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + + +var callCount = 0; +async function* f([...{ x } = []] = []) { + + callCount = callCount + 1; +}; +f().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-rest-not-final-ary.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-rest-not-final-ary.js new file mode 100644 index 0000000000..30829b32c1 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-rest-not-final-ary.js @@ -0,0 +1,39 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-ary.case +// - src/dstr-binding/default/async-gen-func-decl-dflt.template +/*--- +description: Rest element (array binding pattern) may not be followed by any element (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + + +var callCount = 0; +async function* f([...[x], y] = [1, 2, 3]) { + + callCount = callCount + 1; +}; +f().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-rest-not-final-id.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-rest-not-final-id.js new file mode 100644 index 0000000000..61dc0c55af --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-rest-not-final-id.js @@ -0,0 +1,39 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-id.case +// - src/dstr-binding/default/async-gen-func-decl-dflt.template +/*--- +description: Rest element (identifier) may not be followed by any element (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + + +var callCount = 0; +async function* f([...x, y] = [1, 2, 3]) { + + callCount = callCount + 1; +}; +f().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-rest-not-final-obj.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-rest-not-final-obj.js new file mode 100644 index 0000000000..b968e3a5c9 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-rest-not-final-obj.js @@ -0,0 +1,39 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-obj.case +// - src/dstr-binding/default/async-gen-func-decl-dflt.template +/*--- +description: Rest element (object binding pattern) may not be followed by any element (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + + +var callCount = 0; +async function* f([...{ x }, y] = [1, 2, 3]) { + + callCount = callCount + 1; +}; +f().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-rest-obj-id.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-rest-obj-id.js new file mode 100644 index 0000000000..22573b9f72 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-rest-obj-id.js @@ -0,0 +1,42 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-id.case +// - src/dstr-binding/default/async-gen-func-decl-dflt.template +/*--- +description: Rest element containing an object binding pattern (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + + +var callCount = 0; +async function* f([...{ length }] = [1, 2, 3]) { + assert.sameValue(length, 3); + callCount = callCount + 1; +}; +f().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-rest-obj-prop-id.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-rest-obj-prop-id.js new file mode 100644 index 0000000000..1ec00fde2f --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-rest-obj-prop-id.js @@ -0,0 +1,49 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-prop-id.case +// - src/dstr-binding/default/async-gen-func-decl-dflt.template +/*--- +description: Rest element containing an object binding pattern (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +let length = "outer"; + + +var callCount = 0; +async function* f([...{ 0: v, 1: w, 2: x, 3: y, length: z }] = [7, 8, 9]) { + assert.sameValue(v, 7); + assert.sameValue(w, 8); + assert.sameValue(x, 9); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + assert.sameValue(length, "outer", "the length prop is not set as a binding name"); + callCount = callCount + 1; +}; +f().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-init-null.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-init-null.js new file mode 100644 index 0000000000..7666e0fee3 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-init-null.js @@ -0,0 +1,34 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/async-gen-func-decl-dflt.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + + +async function* f({} = null) { + +}; + +assert.throws(TypeError, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-init-undefined.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-init-undefined.js new file mode 100644 index 0000000000..72af21f978 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-init-undefined.js @@ -0,0 +1,34 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/async-gen-func-decl-dflt.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + + +async function* f({} = undefined) { + +}; + +assert.throws(TypeError, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-empty.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-empty.js new file mode 100644 index 0000000000..d09c56d7bb --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-empty.js @@ -0,0 +1,41 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-empty.case +// - src/dstr-binding/default/async-gen-func-decl-dflt.template +/*--- +description: No property access occurs for an "empty" object binding pattern (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ +var accessCount = 0; +var obj = Object.defineProperty({}, 'attr', { + get: function() { + accessCount += 1; + } +}); + + +var callCount = 0; +async function* f({} = obj) { + assert.sameValue(accessCount, 0); + callCount = callCount + 1; +}; +f().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-id-get-value-err.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000..eca4bc75ab --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-id-get-value-err.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-get-value-err.case +// - src/dstr-binding/error/async-gen-func-decl-dflt.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 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* f({ poisoned } = poisonedProperty) { + +}; + +assert.throws(Test262Error, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..305dd74e47 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-id-init-fn-name-arrow.js @@ -0,0 +1,42 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-arrow.case +// - src/dstr-binding/default/async-gen-func-decl-dflt.template +/*--- +description: SingleNameBinding assigns `name` to arrow functions (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + + +var callCount = 0; +async function* f({ arrow = () => {} } = {}) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; +}; +f().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-id-init-fn-name-class.js new file mode 100644 index 0000000000..4c1ffddfc3 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-id-init-fn-name-class.js @@ -0,0 +1,44 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-class.case +// - src/dstr-binding/default/async-gen-func-decl-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + + +var callCount = 0; +async function* f({ cls = class {}, xCls = class X {}, xCls2 = class { static name() {} } } = {}) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + assert.notSameValue(xCls2.name, 'xCls2'); + callCount = callCount + 1; +}; +f().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-id-init-fn-name-cover.js new file mode 100644 index 0000000000..27a82ff7ef --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-id-init-fn-name-cover.js @@ -0,0 +1,43 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-cover.case +// - src/dstr-binding/default/async-gen-func-decl-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + + +var callCount = 0; +async function* f({ cover = (function () {}), xCover = (0, function() {}) } = {}) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; +}; +f().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-id-init-fn-name-fn.js new file mode 100644 index 0000000000..98a366aa31 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-id-init-fn-name-fn.js @@ -0,0 +1,43 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-fn.case +// - src/dstr-binding/default/async-gen-func-decl-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + + +var callCount = 0; +async function* f({ fn = function () {}, xFn = function x() {} } = {}) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; +}; +f().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-id-init-fn-name-gen.js new file mode 100644 index 0000000000..4496b1a371 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-id-init-fn-name-gen.js @@ -0,0 +1,44 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-gen.case +// - src/dstr-binding/default/async-gen-func-decl-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). + +---*/ + + +var callCount = 0; +async function* f({ gen = function* () {}, xGen = function* x() {} } = {}) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; +}; +f().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-id-init-skipped.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-id-init-skipped.js new file mode 100644 index 0000000000..f16fd9dde4 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-id-init-skipped.js @@ -0,0 +1,46 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-skipped.case +// - src/dstr-binding/default/async-gen-func-decl-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + + +var callCount = 0; +async function* f({ w = counter(), x = counter(), y = counter(), z = counter() } = { w: null, x: 0, y: false, z: '' }) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; +}; +f().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-id-init-throws.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000..50b1cf0c36 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-id-init-throws.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/async-gen-func-decl-dflt.template +/*--- +description: Error thrown when evaluating the initializer (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 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* f({ x = thrower() } = {}) { + +}; + +assert.throws(Test262Error, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-id-init-unresolvable.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000..b15b7359c3 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,45 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/async-gen-func-decl-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 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* f({ x = unresolvableReference } = {}) { + +}; + +assert.throws(ReferenceError, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-id-trailing-comma.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-id-trailing-comma.js new file mode 100644 index 0000000000..be253e56a2 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-id-trailing-comma.js @@ -0,0 +1,36 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-trailing-comma.case +// - src/dstr-binding/default/async-gen-func-decl-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + + +var callCount = 0; +async function* f({ x, } = { x: 23 }) { + assert.sameValue(x, 23); + callCount = callCount + 1; +}; +f().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-list-err.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-list-err.js new file mode 100644 index 0000000000..75d1b49d22 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-list-err.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/async-gen-func-decl-dflt.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 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* f({ a, b = thrower(), c = ++initCount } = {}) { + +}; + +assert.throws(Test262Error, function() { + f(); +}); + +assert.sameValue(initCount, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-prop-ary-init.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-prop-ary-init.js new file mode 100644 index 0000000000..6b7db21671 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-prop-ary-init.js @@ -0,0 +1,45 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-init.case +// - src/dstr-binding/default/async-gen-func-decl-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern using initializer (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + + +var callCount = 0; +async function* f({ w: [x, y, z] = [4, 5, 6] } = {}) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; +}; +f().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-prop-ary-trailing-comma.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-prop-ary-trailing-comma.js new file mode 100644 index 0000000000..44112cd71b --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-prop-ary-trailing-comma.js @@ -0,0 +1,36 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-trailing-comma.case +// - src/dstr-binding/default/async-gen-func-decl-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + + +var callCount = 0; +async function* f({ x: [y], } = { x: [45] }) { + assert.sameValue(y,45); + callCount = callCount + 1; +}; +f().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-prop-ary-value-null.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000..118f16b3e8 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-value-null.case +// - src/dstr-binding/error/async-gen-func-decl-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 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* f({ w: [x, y, z] = [4, 5, 6] } = { w: null }) { + +}; + +assert.throws(TypeError, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-prop-ary.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-prop-ary.js new file mode 100644 index 0000000000..552d85c163 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-prop-ary.js @@ -0,0 +1,43 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary.case +// - src/dstr-binding/default/async-gen-func-decl-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern not using initializer (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + + +var callCount = 0; +async function* f({ w: [x, y, z] = [4, 5, 6] } = { w: [7, undefined, ] }) { + assert.sameValue(x, 7); + assert.sameValue(y, undefined); + assert.sameValue(z, undefined); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; +}; +f().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-prop-eval-err.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000..f5e611718d --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-prop-eval-err.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/async-gen-func-decl-dflt.template +/*--- +description: Evaluation of property name returns an abrupt completion (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 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* f({ [thrower()]: x } = {}) { + +}; + +assert.throws(Test262Error, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-prop-id-get-value-err.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000..ef6f3f23e2 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-get-value-err.case +// - src/dstr-binding/error/async-gen-func-decl-dflt.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 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* f({ poisoned: x = ++initEvalCount } = poisonedProperty) { + +}; + +assert.throws(Test262Error, function() { + f(); +}); + +assert.sameValue(initEvalCount, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-prop-id-init-skipped.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-prop-id-init-skipped.js new file mode 100644 index 0000000000..edcc87ceb3 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-prop-id-init-skipped.js @@ -0,0 +1,58 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case +// - src/dstr-binding/default/async-gen-func-decl-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + + +var callCount = 0; +async function* f({ s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() } = { s: null, u: 0, w: false, y: '' }) { + assert.sameValue(t, null); + assert.sameValue(v, 0); + assert.sameValue(x, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + assert.throws(ReferenceError, function() { + s; + }); + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; +}; +f().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-prop-id-init-throws.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000..b0814dabfe --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-throws.case +// - src/dstr-binding/error/async-gen-func-decl-dflt.template +/*--- +description: Error thrown when evaluating the initializer (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 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* f({ x: y = thrower() } = {}) { + +}; + +assert.throws(Test262Error, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-prop-id-init-unresolvable.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000..74ef7127dd --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,45 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-unresolvable.case +// - src/dstr-binding/error/async-gen-func-decl-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 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* f({ x: y = unresolvableReference } = {}) { + +}; + +assert.throws(ReferenceError, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-prop-id-init.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-prop-id-init.js new file mode 100644 index 0000000000..5edab18821 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-prop-id-init.js @@ -0,0 +1,39 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init.case +// - src/dstr-binding/default/async-gen-func-decl-dflt.template +/*--- +description: Binding as specified via property name, identifier, and initializer (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +async function* f({ x: y = 33 } = { }) { + assert.sameValue(y, 33); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; +}; +f().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-prop-id-trailing-comma.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-prop-id-trailing-comma.js new file mode 100644 index 0000000000..308f9f5aca --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-prop-id-trailing-comma.js @@ -0,0 +1,40 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-trailing-comma.case +// - src/dstr-binding/default/async-gen-func-decl-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + + +var callCount = 0; +async function* f({ x: y, } = { x: 23 }) { + assert.sameValue(y, 23); + + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; +}; +f().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-prop-id.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-prop-id.js new file mode 100644 index 0000000000..660995b69d --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-prop-id.js @@ -0,0 +1,39 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id.case +// - src/dstr-binding/default/async-gen-func-decl-dflt.template +/*--- +description: Binding as specified via property name and identifier (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +async function* f({ x: y } = { x: 23 }) { + assert.sameValue(y, 23); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; +}; +f().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-prop-obj-init.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-prop-obj-init.js new file mode 100644 index 0000000000..62ed8e5e15 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-prop-obj-init.js @@ -0,0 +1,45 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-init.case +// - src/dstr-binding/default/async-gen-func-decl-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern using initializer (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + + +var callCount = 0; +async function* f({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: undefined }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; +}; +f().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-prop-obj-value-null.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000..7d4681cde7 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-null.case +// - src/dstr-binding/error/async-gen-func-decl-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 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* f({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: null }) { + +}; + +assert.throws(TypeError, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-prop-obj-value-undef.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000..a241147697 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-undef.case +// - src/dstr-binding/error/async-gen-func-decl-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 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* f({ w: { x, y, z } = undefined } = { }) { + +}; + +assert.throws(TypeError, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-prop-obj.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-prop-obj.js new file mode 100644 index 0000000000..4e1490ec4d --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-prop-obj.js @@ -0,0 +1,43 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj.case +// - src/dstr-binding/default/async-gen-func-decl-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern not using initializer (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + + +var callCount = 0; +async function* f({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: { x: undefined, z: 7 } }) { + assert.sameValue(x, undefined); + assert.sameValue(y, undefined); + assert.sameValue(z, 7); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; +}; +f().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-rest-getter.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-rest-getter.js new file mode 100644 index 0000000000..4cfe3fafe0 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-rest-getter.js @@ -0,0 +1,38 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-getter.case +// - src/dstr-binding/default/async-gen-func-decl-dflt.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [object-rest, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + +---*/ +var count = 0; + + +var callCount = 0; +async function* f({...x} = { get v() { count++; return 2; } }) { + assert.sameValue(count, 1); + + verifyProperty(x, "v", { + enumerable: true, + writable: true, + configurable: true, + value: 2 + }); + callCount = callCount + 1; +}; +f().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-rest-skip-non-enumerable.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..3563a9ae17 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-rest-skip-non-enumerable.js @@ -0,0 +1,46 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-skip-non-enumerable.case +// - src/dstr-binding/default/async-gen-func-decl-dflt.template +/*--- +description: Rest object doesn't contain non-enumerable properties (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [object-rest, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + +---*/ +var o = {a: 3, b: 4}; +Object.defineProperty(o, "x", { value: 4, enumerable: false }); + + +var callCount = 0; +async function* f({...rest} = o) { + assert.sameValue(rest.x, undefined); + + verifyProperty(rest, "a", { + enumerable: true, + writable: true, + configurable: true, + value: 3 + }); + + verifyProperty(rest, "b", { + enumerable: true, + writable: true, + configurable: true, + value: 4 + }); + callCount = callCount + 1; +}; +f().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-rest-val-obj.js b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-rest-val-obj.js new file mode 100644 index 0000000000..a5a3e3b2ca --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/dflt-obj-ptrn-rest-val-obj.js @@ -0,0 +1,45 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-val-obj.case +// - src/dstr-binding/default/async-gen-func-decl-dflt.template +/*--- +description: Rest object contains just unextracted data (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [object-rest, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + +---*/ + + +var callCount = 0; +async function* f({a, b, ...rest} = {x: 1, y: 2, a: 5, b: 3}) { + assert.sameValue(rest.a, undefined); + assert.sameValue(rest.b, undefined); + + verifyProperty(rest, "x", { + enumerable: true, + writable: true, + configurable: true, + value: 1 + }); + + verifyProperty(rest, "y", { + enumerable: true, + writable: true, + configurable: true, + value: 2 + }); + callCount = callCount + 1; +}; +f().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/obj-init-null.js b/js/src/tests/test262/language/statements/async-generator/dstr/obj-init-null.js new file mode 100644 index 0000000000..deeb256b6e --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/obj-init-null.js @@ -0,0 +1,34 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/async-gen-func-decl.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + + +async function* f({}) { + +}; + +assert.throws(TypeError, function() { + f(null); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/obj-init-undefined.js b/js/src/tests/test262/language/statements/async-generator/dstr/obj-init-undefined.js new file mode 100644 index 0000000000..f04f037892 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/obj-init-undefined.js @@ -0,0 +1,34 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/async-gen-func-decl.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + + +async function* f({}) { + +}; + +assert.throws(TypeError, function() { + f(undefined); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-empty.js b/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-empty.js new file mode 100644 index 0000000000..23428d35f0 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-empty.js @@ -0,0 +1,41 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-empty.case +// - src/dstr-binding/default/async-gen-func-decl.template +/*--- +description: No property access occurs for an "empty" object binding pattern (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ +var accessCount = 0; +var obj = Object.defineProperty({}, 'attr', { + get: function() { + accessCount += 1; + } +}); + + +var callCount = 0; +async function* f({}) { + assert.sameValue(accessCount, 0); + callCount = callCount + 1; +}; +f(obj).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-id-get-value-err.js b/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000..1795f3cc65 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-id-get-value-err.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-get-value-err.case +// - src/dstr-binding/error/async-gen-func-decl.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 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* f({ poisoned }) { + +}; + +assert.throws(Test262Error, function() { + f(poisonedProperty); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..237d5f9694 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-id-init-fn-name-arrow.js @@ -0,0 +1,42 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-arrow.case +// - src/dstr-binding/default/async-gen-func-decl.template +/*--- +description: SingleNameBinding assigns `name` to arrow functions (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + + +var callCount = 0; +async function* f({ arrow = () => {} }) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; +}; +f({}).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-id-init-fn-name-class.js new file mode 100644 index 0000000000..e272d987e0 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-id-init-fn-name-class.js @@ -0,0 +1,44 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-class.case +// - src/dstr-binding/default/async-gen-func-decl.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + + +var callCount = 0; +async function* f({ cls = class {}, xCls = class X {}, xCls2 = class { static name() {} } }) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + assert.notSameValue(xCls2.name, 'xCls2'); + callCount = callCount + 1; +}; +f({}).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-id-init-fn-name-cover.js new file mode 100644 index 0000000000..6389dbcb7d --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-id-init-fn-name-cover.js @@ -0,0 +1,43 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-cover.case +// - src/dstr-binding/default/async-gen-func-decl.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + + +var callCount = 0; +async function* f({ cover = (function () {}), xCover = (0, function() {}) }) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; +}; +f({}).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-id-init-fn-name-fn.js new file mode 100644 index 0000000000..1ccd8761ae --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-id-init-fn-name-fn.js @@ -0,0 +1,43 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-fn.case +// - src/dstr-binding/default/async-gen-func-decl.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + + +var callCount = 0; +async function* f({ fn = function () {}, xFn = function x() {} }) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; +}; +f({}).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-id-init-fn-name-gen.js new file mode 100644 index 0000000000..c9679afdfc --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-id-init-fn-name-gen.js @@ -0,0 +1,44 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-gen.case +// - src/dstr-binding/default/async-gen-func-decl.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). + +---*/ + + +var callCount = 0; +async function* f({ gen = function* () {}, xGen = function* x() {} }) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; +}; +f({}).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-id-init-skipped.js b/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-id-init-skipped.js new file mode 100644 index 0000000000..3770316b3d --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-id-init-skipped.js @@ -0,0 +1,46 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-skipped.case +// - src/dstr-binding/default/async-gen-func-decl.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + + +var callCount = 0; +async function* f({ w = counter(), x = counter(), y = counter(), z = counter() }) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; +}; +f({ w: null, x: 0, y: false, z: '' }).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-id-init-throws.js b/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000..34eda335f8 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-id-init-throws.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/async-gen-func-decl.template +/*--- +description: Error thrown when evaluating the initializer (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 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* f({ x = thrower() }) { + +}; + +assert.throws(Test262Error, function() { + f({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-id-init-unresolvable.js b/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000..3e8e754b26 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,45 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/async-gen-func-decl.template +/*--- +description: Destructuring initializer is an unresolvable reference (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 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* f({ x = unresolvableReference }) { + +}; + +assert.throws(ReferenceError, function() { + f({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-id-trailing-comma.js b/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-id-trailing-comma.js new file mode 100644 index 0000000000..3fb2d68313 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-id-trailing-comma.js @@ -0,0 +1,36 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-trailing-comma.case +// - src/dstr-binding/default/async-gen-func-decl.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + + +var callCount = 0; +async function* f({ x, }) { + assert.sameValue(x, 23); + callCount = callCount + 1; +}; +f({ x: 23 }).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-list-err.js b/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-list-err.js new file mode 100644 index 0000000000..2eb05668ef --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-list-err.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/async-gen-func-decl.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 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* f({ a, b = thrower(), c = ++initCount }) { + +}; + +assert.throws(Test262Error, function() { + f({}); +}); + +assert.sameValue(initCount, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-prop-ary-init.js b/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-prop-ary-init.js new file mode 100644 index 0000000000..0f9f618d41 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-prop-ary-init.js @@ -0,0 +1,45 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-init.case +// - src/dstr-binding/default/async-gen-func-decl.template +/*--- +description: Object binding pattern with "nested" array binding pattern using initializer (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + + +var callCount = 0; +async function* f({ w: [x, y, z] = [4, 5, 6] }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; +}; +f({}).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-prop-ary-trailing-comma.js b/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-prop-ary-trailing-comma.js new file mode 100644 index 0000000000..8739c17c46 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-prop-ary-trailing-comma.js @@ -0,0 +1,36 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-trailing-comma.case +// - src/dstr-binding/default/async-gen-func-decl.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + + +var callCount = 0; +async function* f({ x: [y], }) { + assert.sameValue(y,45); + callCount = callCount + 1; +}; +f({ x: [45] }).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-prop-ary-value-null.js b/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000..0ce6940358 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-value-null.case +// - src/dstr-binding/error/async-gen-func-decl.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 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* f({ w: [x, y, z] = [4, 5, 6] }) { + +}; + +assert.throws(TypeError, function() { + f({ w: null }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-prop-ary.js b/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-prop-ary.js new file mode 100644 index 0000000000..121f6a935d --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-prop-ary.js @@ -0,0 +1,43 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary.case +// - src/dstr-binding/default/async-gen-func-decl.template +/*--- +description: Object binding pattern with "nested" array binding pattern not using initializer (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + + +var callCount = 0; +async function* f({ w: [x, y, z] = [4, 5, 6] }) { + assert.sameValue(x, 7); + assert.sameValue(y, undefined); + assert.sameValue(z, undefined); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; +}; +f({ w: [7, undefined, ] }).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-prop-eval-err.js b/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000..83da8522d1 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-prop-eval-err.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/async-gen-func-decl.template +/*--- +description: Evaluation of property name returns an abrupt completion (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 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* f({ [thrower()]: x }) { + +}; + +assert.throws(Test262Error, function() { + f({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-prop-id-get-value-err.js b/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000..dbbae145d7 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-get-value-err.case +// - src/dstr-binding/error/async-gen-func-decl.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 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* f({ poisoned: x = ++initEvalCount }) { + +}; + +assert.throws(Test262Error, function() { + f(poisonedProperty); +}); + +assert.sameValue(initEvalCount, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-prop-id-init-skipped.js b/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-prop-id-init-skipped.js new file mode 100644 index 0000000000..70d3ccd06c --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-prop-id-init-skipped.js @@ -0,0 +1,58 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case +// - src/dstr-binding/default/async-gen-func-decl.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + + +var callCount = 0; +async function* f({ s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() }) { + assert.sameValue(t, null); + assert.sameValue(v, 0); + assert.sameValue(x, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + assert.throws(ReferenceError, function() { + s; + }); + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; +}; +f({ s: null, u: 0, w: false, y: '' }).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-prop-id-init-throws.js b/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000..eca60f73b4 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-throws.case +// - src/dstr-binding/error/async-gen-func-decl.template +/*--- +description: Error thrown when evaluating the initializer (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 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* f({ x: y = thrower() }) { + +}; + +assert.throws(Test262Error, function() { + f({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-prop-id-init-unresolvable.js b/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000..302e84b74c --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,45 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-unresolvable.case +// - src/dstr-binding/error/async-gen-func-decl.template +/*--- +description: Destructuring initializer is an unresolvable reference (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 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* f({ x: y = unresolvableReference }) { + +}; + +assert.throws(ReferenceError, function() { + f({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-prop-id-init.js b/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-prop-id-init.js new file mode 100644 index 0000000000..f93d9daeb7 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-prop-id-init.js @@ -0,0 +1,39 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init.case +// - src/dstr-binding/default/async-gen-func-decl.template +/*--- +description: Binding as specified via property name, identifier, and initializer (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +async function* f({ x: y = 33 }) { + assert.sameValue(y, 33); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; +}; +f({ }).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-prop-id-trailing-comma.js b/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-prop-id-trailing-comma.js new file mode 100644 index 0000000000..e938f19afc --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-prop-id-trailing-comma.js @@ -0,0 +1,40 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-trailing-comma.case +// - src/dstr-binding/default/async-gen-func-decl.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + + +var callCount = 0; +async function* f({ x: y, }) { + assert.sameValue(y, 23); + + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; +}; +f({ x: 23 }).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-prop-id.js b/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-prop-id.js new file mode 100644 index 0000000000..e7aa455720 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-prop-id.js @@ -0,0 +1,39 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id.case +// - src/dstr-binding/default/async-gen-func-decl.template +/*--- +description: Binding as specified via property name and identifier (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +async function* f({ x: y }) { + assert.sameValue(y, 23); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; +}; +f({ x: 23 }).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-prop-obj-init.js b/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-prop-obj-init.js new file mode 100644 index 0000000000..b3afb6e80d --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-prop-obj-init.js @@ -0,0 +1,45 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-init.case +// - src/dstr-binding/default/async-gen-func-decl.template +/*--- +description: Object binding pattern with "nested" object binding pattern using initializer (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + + +var callCount = 0; +async function* f({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; +}; +f({ w: undefined }).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-prop-obj-value-null.js b/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000..7685385e43 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-null.case +// - src/dstr-binding/error/async-gen-func-decl.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 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* f({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) { + +}; + +assert.throws(TypeError, function() { + f({ w: null }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-prop-obj-value-undef.js b/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000..17a2359eaf --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-undef.case +// - src/dstr-binding/error/async-gen-func-decl.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 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* f({ w: { x, y, z } = undefined }) { + +}; + +assert.throws(TypeError, function() { + f({ }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-prop-obj.js b/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-prop-obj.js new file mode 100644 index 0000000000..6656224cd8 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-prop-obj.js @@ -0,0 +1,43 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj.case +// - src/dstr-binding/default/async-gen-func-decl.template +/*--- +description: Object binding pattern with "nested" object binding pattern not using initializer (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + + +var callCount = 0; +async function* f({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) { + assert.sameValue(x, undefined); + assert.sameValue(y, undefined); + assert.sameValue(z, 7); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; +}; +f({ w: { x: undefined, z: 7 } }).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-rest-getter.js b/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-rest-getter.js new file mode 100644 index 0000000000..b68d00047c --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-rest-getter.js @@ -0,0 +1,38 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-getter.case +// - src/dstr-binding/default/async-gen-func-decl.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [object-rest, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + +---*/ +var count = 0; + + +var callCount = 0; +async function* f({...x}) { + assert.sameValue(count, 1); + + verifyProperty(x, "v", { + enumerable: true, + writable: true, + configurable: true, + value: 2 + }); + callCount = callCount + 1; +}; +f({ get v() { count++; return 2; } }).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-rest-skip-non-enumerable.js b/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..14ade21962 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-rest-skip-non-enumerable.js @@ -0,0 +1,46 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-skip-non-enumerable.case +// - src/dstr-binding/default/async-gen-func-decl.template +/*--- +description: Rest object doesn't contain non-enumerable properties (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [object-rest, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + +---*/ +var o = {a: 3, b: 4}; +Object.defineProperty(o, "x", { value: 4, enumerable: false }); + + +var callCount = 0; +async function* f({...rest}) { + assert.sameValue(rest.x, undefined); + + verifyProperty(rest, "a", { + enumerable: true, + writable: true, + configurable: true, + value: 3 + }); + + verifyProperty(rest, "b", { + enumerable: true, + writable: true, + configurable: true, + value: 4 + }); + callCount = callCount + 1; +}; +f(o).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-rest-val-obj.js b/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-rest-val-obj.js new file mode 100644 index 0000000000..60b6b9e206 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/obj-ptrn-rest-val-obj.js @@ -0,0 +1,45 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-val-obj.case +// - src/dstr-binding/default/async-gen-func-decl.template +/*--- +description: Rest object contains just unextracted data (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [object-rest, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + +---*/ + + +var callCount = 0; +async function* f({a, b, ...rest}) { + assert.sameValue(rest.a, undefined); + assert.sameValue(rest.b, undefined); + + verifyProperty(rest, "x", { + enumerable: true, + writable: true, + configurable: true, + value: 1 + }); + + verifyProperty(rest, "y", { + enumerable: true, + writable: true, + configurable: true, + value: 2 + }); + callCount = callCount + 1; +}; +f({x: 1, y: 2, a: 5, b: 3}).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/async-generator/dstr/shell.js b/js/src/tests/test262/language/statements/async-generator/dstr/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/dstr/shell.js |