diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/tests/test262/language/expressions/async-generator | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/language/expressions/async-generator')
633 files changed, 33339 insertions, 0 deletions
diff --git a/js/src/tests/test262/language/expressions/async-generator/array-destructuring-param-strict-body.js b/js/src/tests/test262/language/expressions/async-generator/array-destructuring-param-strict-body.js new file mode 100644 index 0000000000..f784b81fdb --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/array-destructuring-param-strict-body.js @@ -0,0 +1,113 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/array-destructuring-param-strict-body.case +// - src/function-forms/syntax/async-gen-func-expr.template +/*--- +description: ArrayBindingPattern and Use Strict Directive are not allowed to coexist for the same function. (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [rest-parameters, async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.4 Static Semantics: IsSimpleParameterList + + BindingElement : BindingPattern + + 1. Return false. + + 14.1.2 Static Semantics: Early Errors + + FunctionDeclaration : function BindingIdentifier ( FormalParameters ) { FunctionBody } + FunctionDeclaration : function ( FormalParameters ) { FunctionBody } + FunctionExpression : function BindingIdentifier ( FormalParameters ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.2.1 Static Semantics: Early Errors + + ArrowFunction : ArrowParameters => ConciseBody + + - It is a Syntax Error if ContainsUseStrict of ConciseBody is true and + IsSimpleParameterList of ArrowParameters is false. + + 14.3.1 Static Semantics: Early Errors + + MethodDefinition : PropertyName ( UniqueFormalParameters ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + MethodDefinition : set PropertyName ( PropertySetParameterList ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of PropertySetParameterList is false. + + 14.4.1 Static Semantics: Early Errors + + GeneratorMethod : * PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of GeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + GeneratorDeclaration : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + GeneratorExpression : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of GeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + 14.5.1 Static Semantics: Early Errors + + AsyncGeneratorMethod : async * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncGeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + AsyncGeneratorDeclaration : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + AsyncGeneratorDeclaration : async function * ( FormalParameters ) { AsyncGeneratorBody } + AsyncGeneratorExpression : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncGeneratorBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.7.1 Static Semantics: Early Errors + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncFunctionBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + AsyncFunctionDeclaration : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionDeclaration : async function ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionExpression : async function ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionExpression : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncFunctionBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.8.1 Static Semantics: Early Errors + + AsyncArrowFunction : CoverCallExpressionAndAsyncArrowHead => AsyncConciseBody + + - It is a Syntax Error if ContainsUseStrict of AsyncConciseBody is true and + IsSimpleParameterList of CoverCallExpressionAndAsyncArrowHead is false. + +---*/ +$DONOTEVALUATE(); + + +0, async function*([element]) { + "use strict"; +}; diff --git a/js/src/tests/test262/language/expressions/async-generator/await-as-binding-identifier-escaped.js b/js/src/tests/test262/language/expressions/async-generator/await-as-binding-identifier-escaped.js new file mode 100644 index 0000000000..2cd503c078 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/await-as-binding-identifier-escaped.js @@ -0,0 +1,32 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-generators/await-as-binding-identifier-escaped.case +// - src/async-generators/syntax/async-expression.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + BindingIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +$DONOTEVALUATE(); + + +var gen = async function *() { + var \u0061wait; +}; diff --git a/js/src/tests/test262/language/expressions/async-generator/await-as-binding-identifier.js b/js/src/tests/test262/language/expressions/async-generator/await-as-binding-identifier.js new file mode 100644 index 0000000000..fcabda660d --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/await-as-binding-identifier.js @@ -0,0 +1,32 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-generators/await-as-binding-identifier.case +// - src/async-generators/syntax/async-expression.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + BindingIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +$DONOTEVALUATE(); + + +var gen = async function *() { + var await; +}; diff --git a/js/src/tests/test262/language/expressions/async-generator/await-as-identifier-reference-escaped.js b/js/src/tests/test262/language/expressions/async-generator/await-as-identifier-reference-escaped.js new file mode 100644 index 0000000000..5a0c21c9b0 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/await-as-identifier-reference-escaped.js @@ -0,0 +1,32 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-generators/await-as-identifier-reference-escaped.case +// - src/async-generators/syntax/async-expression.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + IdentifierReference : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +$DONOTEVALUATE(); + + +var gen = async function *() { + void \u0061wait; +}; diff --git a/js/src/tests/test262/language/expressions/async-generator/await-as-identifier-reference.js b/js/src/tests/test262/language/expressions/async-generator/await-as-identifier-reference.js new file mode 100644 index 0000000000..6c90eb6de0 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/await-as-identifier-reference.js @@ -0,0 +1,32 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-generators/await-as-identifier-reference.case +// - src/async-generators/syntax/async-expression.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + IdentifierReference : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +$DONOTEVALUATE(); + + +var gen = async function *() { + void await; +}; diff --git a/js/src/tests/test262/language/expressions/async-generator/await-as-label-identifier-escaped.js b/js/src/tests/test262/language/expressions/async-generator/await-as-label-identifier-escaped.js new file mode 100644 index 0000000000..7a02e08b63 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/await-as-label-identifier-escaped.js @@ -0,0 +1,32 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-generators/await-as-label-identifier-escaped.case +// - src/async-generators/syntax/async-expression.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a label identifier. (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + LabelIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +$DONOTEVALUATE(); + + +var gen = async function *() { + \u0061wait: ; +}; diff --git a/js/src/tests/test262/language/expressions/async-generator/await-as-label-identifier.js b/js/src/tests/test262/language/expressions/async-generator/await-as-label-identifier.js new file mode 100644 index 0000000000..0c53650007 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/await-as-label-identifier.js @@ -0,0 +1,32 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-generators/await-as-label-identifier.case +// - src/async-generators/syntax/async-expression.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a label identifier. (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + LabelIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +$DONOTEVALUATE(); + + +var gen = async function *() { + await: ; +}; diff --git a/js/src/tests/test262/language/expressions/async-generator/browser.js b/js/src/tests/test262/language/expressions/async-generator/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/browser.js diff --git a/js/src/tests/test262/language/expressions/async-generator/default-proto.js b/js/src/tests/test262/language/expressions/async-generator/default-proto.js new file mode 100644 index 0000000000..0a3c32591f --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/default-proto.js @@ -0,0 +1,53 @@ +// Copyright (C) 2019 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-asyncgenerator-definitions-evaluatebody +description: > + Default [[Prototype]] value derived from realm of the async generator function. +info: | + Runtime Semantics: EvaluateBody + + ... + 2. Let generator be ? OrdinaryCreateFromConstructor(functionObject, "%AsyncGeneratorPrototype%", « ... »). + 3. Perform ! AsyncGeneratorStart(generator, FunctionBody). + 4. Return Completion { [[Type]]: return, [[Value]]: generator, [[Target]]: empty }. + + OrdinaryCreateFromConstructor ( constructor, intrinsicDefaultProto [ , internalSlotsList ] ) + + ... + 2. Let proto be ? GetPrototypeFromConstructor(constructor, intrinsicDefaultProto). + 3. Return ObjectCreate(proto, internalSlotsList). + + GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto ) + + ... + 3. Let proto be ? Get(constructor, 'prototype'). + 4. If Type(proto) is not Object, then + a. Let realm be ? GetFunctionRealm(constructor). + b. Set proto to realm's intrinsic object named intrinsicDefaultProto. + 5. Return proto. +features: [async-iteration, Symbol] +---*/ + +var fn = async function* () {}; +var AsyncGeneratorPrototype = Object.getPrototypeOf(fn.prototype); + +fn.prototype = undefined; +assert.sameValue(Object.getPrototypeOf(fn()), AsyncGeneratorPrototype, 'fn.prototype is undefined'); + +fn.prototype = null; +assert.sameValue(Object.getPrototypeOf(fn()), AsyncGeneratorPrototype, 'fn.prototype is null'); + +fn.prototype = false; +assert.sameValue(Object.getPrototypeOf(fn()), AsyncGeneratorPrototype, 'fn.prototype is a Boolean'); + +fn.prototype = ''; +assert.sameValue(Object.getPrototypeOf(fn()), AsyncGeneratorPrototype, 'fn.prototype is a String'); + +fn.prototype = Symbol(); +assert.sameValue(Object.getPrototypeOf(fn()), AsyncGeneratorPrototype, 'fn.prototype is a Symbol'); + +fn.prototype = 1; +assert.sameValue(Object.getPrototypeOf(fn()), AsyncGeneratorPrototype, 'fn.prototype is a Number'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dflt-params-abrupt.js b/js/src/tests/test262/language/expressions/async-generator/dflt-params-abrupt.js new file mode 100644 index 0000000000..17d59b1006 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dflt-params-abrupt.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-abrupt.case +// - src/function-forms/error/async-gen-func-expr.template +/*--- +description: Abrupt completion returned by evaluation of initializer (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [default-parameters, async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. + +---*/ + + +var callCount = 0; +var f; +f = async function*(_ = (function() { throw new Test262Error(); }())) { + + callCount = callCount + 1; +}; + +assert.throws(Test262Error, function() { + f(); +}); +assert.sameValue(callCount, 0, 'generator function body not evaluated'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dflt-params-arg-val-not-undefined.js b/js/src/tests/test262/language/expressions/async-generator/dflt-params-arg-val-not-undefined.js new file mode 100644 index 0000000000..d31b712980 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dflt-params-arg-val-not-undefined.js @@ -0,0 +1,66 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-arg-val-not-undefined.case +// - src/function-forms/default/async-gen-func-expr.template +/*--- +description: Use of initializer when argument value is not `undefined` (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [default-parameters, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + [...] + 23. Let iteratorRecord be Record {[[Iterator]]: + CreateListIterator(argumentsList), [[Done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + a. Perform ? IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + +---*/ +var obj = {}; +var falseCount = 0; +var stringCount = 0; +var nanCount = 0; +var zeroCount = 0; +var nullCount = 0; +var objCount = 0; + + +var callCount = 0; +// Stores a reference `ref` for case evaluation +var ref; +ref = async function*(aFalse = falseCount +=1, aString = stringCount += 1, aNaN = nanCount += 1, a0 = zeroCount += 1, aNull = nullCount += 1, aObj = objCount +=1) { + assert.sameValue(aFalse, false); + assert.sameValue(aString, ''); + assert.sameValue(aNaN, NaN); + assert.sameValue(a0, 0); + assert.sameValue(aNull, null); + assert.sameValue(aObj, obj); + callCount = callCount + 1; +}; + +ref(false, '', NaN, 0, null, obj).next().then(() => { + assert.sameValue(callCount, 1, 'generator function invoked exactly once'); +}).then($DONE, $DONE); + +assert.sameValue(falseCount, 0, 'initializer not evaluated: false'); +assert.sameValue(stringCount, 0, 'initializer not evaluated: string'); +assert.sameValue(nanCount, 0, 'initializer not evaluated: NaN'); +assert.sameValue(zeroCount, 0, 'initializer not evaluated: 0'); +assert.sameValue(nullCount, 0, 'initializer not evaluated: null'); +assert.sameValue(objCount, 0, 'initializer not evaluated: object'); diff --git a/js/src/tests/test262/language/expressions/async-generator/dflt-params-arg-val-undefined.js b/js/src/tests/test262/language/expressions/async-generator/dflt-params-arg-val-undefined.js new file mode 100644 index 0000000000..cb336ce231 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dflt-params-arg-val-undefined.js @@ -0,0 +1,49 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-arg-val-undefined.case +// - src/function-forms/default/async-gen-func-expr.template +/*--- +description: Use of initializer when argument value is `undefined` (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [default-parameters, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + [...] + 23. Let iteratorRecord be Record {[[Iterator]]: + CreateListIterator(argumentsList), [[Done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + a. Perform ? IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + +---*/ + + +var callCount = 0; +// Stores a reference `ref` for case evaluation +var ref; +ref = async function*(fromLiteral = 23, fromExpr = 45, fromHole = 99) { + assert.sameValue(fromLiteral, 23); + assert.sameValue(fromExpr, 45); + assert.sameValue(fromHole, 99); + callCount = callCount + 1; +}; + +ref(undefined, void 0).next().then(() => { + assert.sameValue(callCount, 1, 'generator function invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/async-generator/dflt-params-duplicates.js b/js/src/tests/test262/language/expressions/async-generator/dflt-params-duplicates.js new file mode 100644 index 0000000000..f1958d74b7 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dflt-params-duplicates.js @@ -0,0 +1,42 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-duplicates.case +// - src/function-forms/syntax/async-gen-func-expr.template +/*--- +description: It is a Syntax Error if BoundNames of FormalParameters contains any duplicate elements. (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [default-parameters, async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 14.1.2 Static Semantics: Early Errors + + StrictFormalParameters : FormalParameters + + - It is a Syntax Error if BoundNames of FormalParameters contains any + duplicate elements. + + FormalParameters : FormalParameterList + + - It is a Syntax Error if IsSimpleParameterList of FormalParameterList is + false and BoundNames of FormalParameterList contains any duplicate + elements. + +---*/ +$DONOTEVALUATE(); + + +0, async function*(x = 0, x) { + +}; diff --git a/js/src/tests/test262/language/expressions/async-generator/dflt-params-ref-later.js b/js/src/tests/test262/language/expressions/async-generator/dflt-params-ref-later.js new file mode 100644 index 0000000000..14c63f3d22 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dflt-params-ref-later.js @@ -0,0 +1,45 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-ref-later.case +// - src/function-forms/error/async-gen-func-expr.template +/*--- +description: Referencing a parameter that occurs later in the ParameterList (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [default-parameters, async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. + +---*/ +var x = 0; + + +var callCount = 0; +var f; +f = async function*(x = y, y) { + + callCount = callCount + 1; +}; + +assert.throws(ReferenceError, function() { + f(); +}); +assert.sameValue(callCount, 0, 'generator function body not evaluated'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dflt-params-ref-prior.js b/js/src/tests/test262/language/expressions/async-generator/dflt-params-ref-prior.js new file mode 100644 index 0000000000..94a5a0fe46 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dflt-params-ref-prior.js @@ -0,0 +1,46 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-ref-prior.case +// - src/function-forms/default/async-gen-func-expr.template +/*--- +description: Referencing a parameter that occurs earlier in the ParameterList (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [default-parameters, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. + +---*/ +var x = 0; + + +var callCount = 0; +// Stores a reference `ref` for case evaluation +var ref; +ref = async function*(x, y = x, z = y) { + assert.sameValue(x, 3, 'first argument value'); + assert.sameValue(y, 3, 'second argument value'); + assert.sameValue(z, 3, 'third argument value'); + callCount = callCount + 1; +}; + +ref(3).next().then(() => { + assert.sameValue(callCount, 1, 'generator function invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/async-generator/dflt-params-ref-self.js b/js/src/tests/test262/language/expressions/async-generator/dflt-params-ref-self.js new file mode 100644 index 0000000000..cb5edc0a37 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dflt-params-ref-self.js @@ -0,0 +1,45 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-ref-self.case +// - src/function-forms/error/async-gen-func-expr.template +/*--- +description: Referencing a parameter from within its own initializer (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [default-parameters, async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. + +---*/ +var x = 0; + + +var callCount = 0; +var f; +f = async function*(x = x) { + + callCount = callCount + 1; +}; + +assert.throws(ReferenceError, function() { + f(); +}); +assert.sameValue(callCount, 0, 'generator function body not evaluated'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dflt-params-rest.js b/js/src/tests/test262/language/expressions/async-generator/dflt-params-rest.js new file mode 100644 index 0000000000..ec30e10335 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dflt-params-rest.js @@ -0,0 +1,46 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-rest.case +// - src/function-forms/syntax/async-gen-func-expr.template +/*--- +description: RestParameter does not support an initializer (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [default-parameters, async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 14.1 Function Definitions + + Syntax + + FunctionRestParameter[Yield] : + + BindingRestElement[?Yield] + + 13.3.3 Destructuring Binding Patterns + + Syntax + + BindingRestElement[Yield] : + + ...BindingIdentifier[?Yield] + ...BindingPattern[?Yield] + +---*/ +$DONOTEVALUATE(); + + +0, async function*(...x = []) { + +}; diff --git a/js/src/tests/test262/language/expressions/async-generator/dflt-params-trailing-comma.js b/js/src/tests/test262/language/expressions/async-generator/dflt-params-trailing-comma.js new file mode 100644 index 0000000000..9ac29e9f5d --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dflt-params-trailing-comma.js @@ -0,0 +1,41 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-trailing-comma.case +// - src/function-forms/default/async-gen-func-expr.template +/*--- +description: A trailing comma should not increase the respective length, using default parameters (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + Trailing comma in the parameters list + + 14.1 Function Definitions + + FormalParameters[Yield, Await] : FormalParameterList[?Yield, ?Await] , +---*/ + + +var callCount = 0; +// Stores a reference `ref` for case evaluation +var ref; +ref = async function*(a, b = 39,) { + assert.sameValue(a, 42); + assert.sameValue(b, 39); + callCount = callCount + 1; +}; + +ref(42, undefined, 1).next().then(() => { + assert.sameValue(callCount, 1, 'generator function invoked exactly once'); +}).then($DONE, $DONE); + +assert.sameValue(ref.length, 1, 'length is properly set'); diff --git a/js/src/tests/test262/language/expressions/async-generator/dstr/ary-init-iter-close.js b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-init-iter-close.js new file mode 100644 index 0000000000..1dcc3e2656 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-init-iter-close.js @@ -0,0 +1,54 @@ +// |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-expr.template +/*--- +description: Iterator is closed when not exhausted by pattern evaluation (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([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/expressions/async-generator/dstr/ary-init-iter-get-err-array-prototype.js b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-init-iter-get-err-array-prototype.js new file mode 100644 index 0000000000..5cb585bbbf --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-init-iter-get-err-array-prototype.js @@ -0,0 +1,47 @@ +// 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-expr.template +/*--- +description: Abrupt completion returned by GetIterator (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [Symbol.iterator, async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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]; + + +var f; +f = async function*([x, y, z]) { + +}; + +assert.throws(TypeError, function() { + f([1, 2, 3]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dstr/ary-init-iter-get-err.js b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-init-iter-get-err.js new file mode 100644 index 0000000000..67b9f20367 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-init-iter-get-err.js @@ -0,0 +1,41 @@ +// 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-expr.template +/*--- +description: Abrupt completion returned by GetIterator (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [Symbol.iterator, async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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(); +}; + + +var f; +f = async function*([x]) { + +}; + +assert.throws(Test262Error, function() { + f(iter); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dstr/ary-init-iter-no-close.js b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-init-iter-no-close.js new file mode 100644 index 0000000000..44864fc314 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-init-iter-no-close.js @@ -0,0 +1,54 @@ +// |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-expr.template +/*--- +description: Iterator is not closed when exhausted by pattern evaluation (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([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/expressions/async-generator/dstr/ary-name-iter-val.js b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-name-iter-val.js new file mode 100644 index 0000000000..48ed914025 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-name-iter-val.js @@ -0,0 +1,53 @@ +// |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-expr.template +/*--- +description: SingleNameBinding with normal value iteration (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([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/expressions/async-generator/dstr/ary-ptrn-elem-ary-elem-init.js b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-elem-ary-elem-init.js new file mode 100644 index 0000000000..2d0e070008 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-elem-ary-elem-init.js @@ -0,0 +1,45 @@ +// |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-expr.template +/*--- +description: BindingElement with array binding pattern and initializer is used (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([[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/expressions/async-generator/dstr/ary-ptrn-elem-ary-elem-iter.js b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-elem-ary-elem-iter.js new file mode 100644 index 0000000000..266dc51dec --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-elem-ary-elem-iter.js @@ -0,0 +1,46 @@ +// |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-expr.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([[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/expressions/async-generator/dstr/ary-ptrn-elem-ary-elision-init.js b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-elem-ary-elision-init.js new file mode 100644 index 0000000000..a49d427ea2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-elem-ary-elision-init.js @@ -0,0 +1,52 @@ +// |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-expr.template +/*--- +description: BindingElement with array binding pattern and initializer is used (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([[,] = 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/expressions/async-generator/dstr/ary-ptrn-elem-ary-elision-iter.js b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-elem-ary-elision-iter.js new file mode 100644 index 0000000000..cc70c99292 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-elem-ary-elision-iter.js @@ -0,0 +1,49 @@ +// |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-expr.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([[,] = 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/expressions/async-generator/dstr/ary-ptrn-elem-ary-empty-init.js b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-elem-ary-empty-init.js new file mode 100644 index 0000000000..a37748b75b --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-elem-ary-empty-init.js @@ -0,0 +1,48 @@ +// |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-expr.template +/*--- +description: BindingElement with array binding pattern and initializer is used (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([[] = 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/expressions/async-generator/dstr/ary-ptrn-elem-ary-empty-iter.js b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-elem-ary-empty-iter.js new file mode 100644 index 0000000000..e5a2e43d6f --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-elem-ary-empty-iter.js @@ -0,0 +1,45 @@ +// |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-expr.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([[] = 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/expressions/async-generator/dstr/ary-ptrn-elem-ary-rest-init.js b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-elem-ary-rest-init.js new file mode 100644 index 0000000000..19f0aea85c --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-elem-ary-rest-init.js @@ -0,0 +1,49 @@ +// |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-expr.template +/*--- +description: BindingElement with array binding pattern and initializer is used (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([[...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/expressions/async-generator/dstr/ary-ptrn-elem-ary-rest-iter.js b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-elem-ary-rest-iter.js new file mode 100644 index 0000000000..83f4a32015 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-elem-ary-rest-iter.js @@ -0,0 +1,52 @@ +// |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-expr.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([[...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/expressions/async-generator/dstr/ary-ptrn-elem-ary-val-null.js b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000..2b1f1614e3 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,48 @@ +// 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-expr.template +/*--- +description: Nested array destructuring with a null value (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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). +---*/ + + +var f; +f = async function*([[x]]) { + +}; + +assert.throws(TypeError, function() { + f([null]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-elem-id-init-exhausted.js b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-elem-id-init-exhausted.js new file mode 100644 index 0000000000..cc796ac033 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-elem-id-init-exhausted.js @@ -0,0 +1,44 @@ +// |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-expr.template +/*--- +description: Destructuring initializer with an exhausted iterator (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([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/expressions/async-generator/dstr/ary-ptrn-elem-id-init-fn-name-arrow.js b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-elem-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..29069b8512 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-elem-id-init-fn-name-arrow.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-arrow.case +// - src/dstr-binding/default/async-gen-func-expr.template +/*--- +description: SingleNameBinding does assign name to arrow functions (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([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/expressions/async-generator/dstr/ary-ptrn-elem-id-init-fn-name-class.js b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-elem-id-init-fn-name-class.js new file mode 100644 index 0000000000..ad46341436 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-elem-id-init-fn-name-class.js @@ -0,0 +1,47 @@ +// |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-expr.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([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/expressions/async-generator/dstr/ary-ptrn-elem-id-init-fn-name-cover.js b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-elem-id-init-fn-name-cover.js new file mode 100644 index 0000000000..976a55fd0d --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-elem-id-init-fn-name-cover.js @@ -0,0 +1,46 @@ +// |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-expr.template +/*--- +description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([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/expressions/async-generator/dstr/ary-ptrn-elem-id-init-fn-name-fn.js b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-elem-id-init-fn-name-fn.js new file mode 100644 index 0000000000..c3f876d535 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-elem-id-init-fn-name-fn.js @@ -0,0 +1,46 @@ +// |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-expr.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([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/expressions/async-generator/dstr/ary-ptrn-elem-id-init-fn-name-gen.js b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-elem-id-init-fn-name-gen.js new file mode 100644 index 0000000000..082991adf5 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-elem-id-init-fn-name-gen.js @@ -0,0 +1,47 @@ +// |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-expr.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([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/expressions/async-generator/dstr/ary-ptrn-elem-id-init-hole.js b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-elem-id-init-hole.js new file mode 100644 index 0000000000..5ce49a08c2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-elem-id-init-hole.js @@ -0,0 +1,40 @@ +// |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-expr.template +/*--- +description: Destructuring initializer with a "hole" (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([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/expressions/async-generator/dstr/ary-ptrn-elem-id-init-skipped.js b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-elem-id-init-skipped.js new file mode 100644 index 0000000000..9363556383 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-elem-id-init-skipped.js @@ -0,0 +1,49 @@ +// |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-expr.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([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/expressions/async-generator/dstr/ary-ptrn-elem-id-init-throws.js b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000..4e1e78a6d1 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,39 @@ +// 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-expr.template +/*--- +description: Destructuring initializer returns an abrupt completion (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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). +---*/ + + +var f; +f = async function*([x = (function() { throw new Test262Error(); })()]) { + +}; + +assert.throws(Test262Error, function() { + f([undefined]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-elem-id-init-undef.js b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-elem-id-init-undef.js new file mode 100644 index 0000000000..f5a99edcba --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-elem-id-init-undef.js @@ -0,0 +1,43 @@ +// |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-expr.template +/*--- +description: Destructuring initializer with an undefined value (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([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/expressions/async-generator/dstr/ary-ptrn-elem-id-init-unresolvable.js b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000..75a446295c --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,46 @@ +// 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-expr.template +/*--- +description: Destructuring initializer is an unresolvable reference (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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. +---*/ + + +var f; +f = async function*([ x = unresolvableReference ]) { + +}; + +assert.throws(ReferenceError, function() { + f([]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-elem-id-iter-complete.js b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-elem-id-iter-complete.js new file mode 100644 index 0000000000..26a57379c7 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-elem-id-iter-complete.js @@ -0,0 +1,47 @@ +// |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-expr.template +/*--- +description: SingleNameBinding when value iteration completes (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([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/expressions/async-generator/dstr/ary-ptrn-elem-id-iter-done.js b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-elem-id-iter-done.js new file mode 100644 index 0000000000..2ea2da95af --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-elem-id-iter-done.js @@ -0,0 +1,42 @@ +// |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-expr.template +/*--- +description: SingleNameBinding when value iteration was completed previously (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([_, 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/expressions/async-generator/dstr/ary-ptrn-elem-id-iter-step-err.js b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000..26a2d14faa --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,48 @@ +// 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-expr.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [Symbol.iterator, async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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(); + } + }; +}; + + +var f; +f = async function*([x]) { + +}; + +assert.throws(Test262Error, function() { + f(g); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-elem-id-iter-val-array-prototype.js b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-elem-id-iter-val-array-prototype.js new file mode 100644 index 0000000000..73d25c1705 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-elem-id-iter-val-array-prototype.js @@ -0,0 +1,63 @@ +// |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-expr.template +/*--- +description: Array destructuring uses overriden Array.prototype[Symbol.iterator] (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [Symbol.iterator, generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([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/expressions/async-generator/dstr/ary-ptrn-elem-id-iter-val-err.js b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000..b02564fff1 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,59 @@ +// 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-expr.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [Symbol.iterator, async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; + } + }; +}; + + +var f; +f = async function*([x]) { + +}; + +assert.throws(Test262Error, function() { + f(g); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-elem-id-iter-val.js b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-elem-id-iter-val.js new file mode 100644 index 0000000000..6697962b06 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-elem-id-iter-val.js @@ -0,0 +1,53 @@ +// |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-expr.template +/*--- +description: SingleNameBinding when value iteration was completed previously (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([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/expressions/async-generator/dstr/ary-ptrn-elem-obj-id-init.js b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-elem-obj-id-init.js new file mode 100644 index 0000000000..ea0eef697a --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-elem-obj-id-init.js @@ -0,0 +1,45 @@ +// |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-expr.template +/*--- +description: BindingElement with object binding pattern and initializer is used (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([{ 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/expressions/async-generator/dstr/ary-ptrn-elem-obj-id.js b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-elem-obj-id.js new file mode 100644 index 0000000000..7ff4b3d066 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-elem-obj-id.js @@ -0,0 +1,45 @@ +// |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-expr.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([{ 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/expressions/async-generator/dstr/ary-ptrn-elem-obj-prop-id-init.js b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-elem-obj-prop-id-init.js new file mode 100644 index 0000000000..1e4325e2db --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-elem-obj-prop-id-init.js @@ -0,0 +1,55 @@ +// |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-expr.template +/*--- +description: BindingElement with object binding pattern and initializer is used (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([{ 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/expressions/async-generator/dstr/ary-ptrn-elem-obj-prop-id.js b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-elem-obj-prop-id.js new file mode 100644 index 0000000000..e2010ffac4 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-elem-obj-prop-id.js @@ -0,0 +1,55 @@ +// |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-expr.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([{ 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/expressions/async-generator/dstr/ary-ptrn-elem-obj-val-null.js b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000..9d1a82fc2a --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,48 @@ +// 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-expr.template +/*--- +description: Nested object destructuring with a null value (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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). +---*/ + + +var f; +f = async function*([{ x }]) { + +}; + +assert.throws(TypeError, function() { + f([null]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-elem-obj-val-undef.js b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000..d580f6a081 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,48 @@ +// 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-expr.template +/*--- +description: Nested object destructuring with a value of `undefined` (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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). +---*/ + + +var f; +f = async function*([{ x }]) { + +}; + +assert.throws(TypeError, function() { + f([]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-elision-exhausted.js b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-elision-exhausted.js new file mode 100644 index 0000000000..cd6b7abcab --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-elision-exhausted.js @@ -0,0 +1,50 @@ +// |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-expr.template +/*--- +description: Elision accepts exhausted iterator (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([,]) { + + 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/expressions/async-generator/dstr/ary-ptrn-elision-step-err.js b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000..c474cf744f --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-elision-step-err.js @@ -0,0 +1,55 @@ +// 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-expr.template +/*--- +description: Elision advances iterator and forwards abrupt completions (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [generators, async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +}(); + + +var f; +f = async function*([,]) { + +}; + +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/expressions/async-generator/dstr/ary-ptrn-elision.js b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-elision.js new file mode 100644 index 0000000000..3c4cb4a8c0 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-elision.js @@ -0,0 +1,59 @@ +// |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-expr.template +/*--- +description: Elision advances iterator (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([,]) { + 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/expressions/async-generator/dstr/ary-ptrn-empty.js b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-empty.js new file mode 100644 index 0000000000..023be481b4 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-empty.js @@ -0,0 +1,42 @@ +// |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-expr.template +/*--- +description: No iteration occurs for an "empty" array binding pattern (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([]) { + 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/expressions/async-generator/dstr/ary-ptrn-rest-ary-elem.js b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-rest-ary-elem.js new file mode 100644 index 0000000000..e13b0cfc47 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-rest-ary-elem.js @@ -0,0 +1,66 @@ +// |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-expr.template +/*--- +description: Rest element containing an array BindingElementList pattern (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([...[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/expressions/async-generator/dstr/ary-ptrn-rest-ary-elision.js b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-rest-ary-elision.js new file mode 100644 index 0000000000..294b44e669 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-rest-ary-elision.js @@ -0,0 +1,72 @@ +// |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-expr.template +/*--- +description: Rest element containing an elision (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([...[,]]) { + 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/expressions/async-generator/dstr/ary-ptrn-rest-ary-empty.js b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-rest-ary-empty.js new file mode 100644 index 0000000000..63ef39c650 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-rest-ary-empty.js @@ -0,0 +1,55 @@ +// |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-expr.template +/*--- +description: Rest element containing an "empty" array pattern (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([...[]]) { + 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/expressions/async-generator/dstr/ary-ptrn-rest-ary-rest.js b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-rest-ary-rest.js new file mode 100644 index 0000000000..9176882e76 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-rest-ary-rest.js @@ -0,0 +1,51 @@ +// |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-expr.template +/*--- +description: Rest element containing a rest element (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([...[...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/expressions/async-generator/dstr/ary-ptrn-rest-id-direct.js b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-rest-id-direct.js new file mode 100644 index 0000000000..7bcc2d0d53 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-rest-id-direct.js @@ -0,0 +1,46 @@ +// |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-expr.template +/*--- +description: Lone rest element (direct binding) (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +includes: [compareArray.js] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([...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/expressions/async-generator/dstr/ary-ptrn-rest-id-elision-next-err.js b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000..9a11688bb7 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,41 @@ +// 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-expr.template +/*--- +description: Rest element following elision elements (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [generators, async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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(); })(); + + +var f; +f = async function*([, ...x]) { + +}; + +assert.throws(Test262Error, function() { + f(iter); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-rest-id-elision.js b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-rest-id-elision.js new file mode 100644 index 0000000000..9849f08ca2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-rest-id-elision.js @@ -0,0 +1,47 @@ +// |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-expr.template +/*--- +description: Rest element following elision elements (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([ , , ...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/expressions/async-generator/dstr/ary-ptrn-rest-id-exhausted.js b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-rest-id-exhausted.js new file mode 100644 index 0000000000..0f5e4b5117 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-rest-id-exhausted.js @@ -0,0 +1,43 @@ +// |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-expr.template +/*--- +description: RestElement applied to an exhausted iterator (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([, , ...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/expressions/async-generator/dstr/ary-ptrn-rest-id-iter-step-err.js b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000..2045ded696 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,52 @@ +// 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-expr.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [generators, async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +}(); + + +var f; +f = async function*([...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/expressions/async-generator/dstr/ary-ptrn-rest-id-iter-val-err.js b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000..8a82af9983 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,54 @@ +// 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-expr.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [Symbol.iterator, async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; + } + }; +}; + + +var f; +f = async function*([...x]) { + +}; + +assert.throws(Test262Error, function() { + f(iter); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-rest-id.js b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-rest-id.js new file mode 100644 index 0000000000..4f05e3a47c --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-rest-id.js @@ -0,0 +1,44 @@ +// |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-expr.template +/*--- +description: Lone rest element (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([...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/expressions/async-generator/dstr/ary-ptrn-rest-init-ary.js b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-rest-init-ary.js new file mode 100644 index 0000000000..7a760e18fe --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-rest-init-ary.js @@ -0,0 +1,41 @@ +// |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-expr.template +/*--- +description: Rest element (nested array pattern) does not support initializer (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async 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/expressions/async-generator/dstr/ary-ptrn-rest-init-id.js b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-rest-init-id.js new file mode 100644 index 0000000000..98ed74335e --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-rest-init-id.js @@ -0,0 +1,41 @@ +// |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-expr.template +/*--- +description: Rest element (identifier) does not support initializer (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async 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/expressions/async-generator/dstr/ary-ptrn-rest-init-obj.js b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-rest-init-obj.js new file mode 100644 index 0000000000..f94136a18a --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-rest-init-obj.js @@ -0,0 +1,41 @@ +// |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-expr.template +/*--- +description: Rest element (nested object pattern) does not support initializer (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async 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/expressions/async-generator/dstr/ary-ptrn-rest-not-final-ary.js b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-rest-not-final-ary.js new file mode 100644 index 0000000000..d72f4adf31 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-rest-not-final-ary.js @@ -0,0 +1,41 @@ +// |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-expr.template +/*--- +description: Rest element (array binding pattern) may not be followed by any element (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([...[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/expressions/async-generator/dstr/ary-ptrn-rest-not-final-id.js b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-rest-not-final-id.js new file mode 100644 index 0000000000..095c4664ac --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-rest-not-final-id.js @@ -0,0 +1,41 @@ +// |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-expr.template +/*--- +description: Rest element (identifier) may not be followed by any element (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([...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/expressions/async-generator/dstr/ary-ptrn-rest-not-final-obj.js b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-rest-not-final-obj.js new file mode 100644 index 0000000000..0841df9c51 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-rest-not-final-obj.js @@ -0,0 +1,41 @@ +// |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-expr.template +/*--- +description: Rest element (object binding pattern) may not be followed by any element (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([...{ 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/expressions/async-generator/dstr/ary-ptrn-rest-obj-id.js b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-rest-obj-id.js new file mode 100644 index 0000000000..c93cf6858f --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-rest-obj-id.js @@ -0,0 +1,44 @@ +// |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-expr.template +/*--- +description: Rest element containing an object binding pattern (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([...{ 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/expressions/async-generator/dstr/ary-ptrn-rest-obj-prop-id.js b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-rest-obj-prop-id.js new file mode 100644 index 0000000000..a7d413e7ce --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/ary-ptrn-rest-obj-prop-id.js @@ -0,0 +1,51 @@ +// |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-expr.template +/*--- +description: Rest element containing an object binding pattern (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([...{ 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/expressions/async-generator/dstr/browser.js b/js/src/tests/test262/language/expressions/async-generator/dstr/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/browser.js diff --git a/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-init-iter-close.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-init-iter-close.js new file mode 100644 index 0000000000..2910c7d0ac --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-init-iter-close.js @@ -0,0 +1,54 @@ +// |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-expr-dflt.template +/*--- +description: Iterator is closed when not exhausted by pattern evaluation (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([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/expressions/async-generator/dstr/dflt-ary-init-iter-get-err-array-prototype.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-init-iter-get-err-array-prototype.js new file mode 100644 index 0000000000..26002b049d --- /dev/null +++ b/js/src/tests/test262/language/expressions/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-expr-dflt.template +/*--- +description: Abrupt completion returned by GetIterator (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [Symbol.iterator, async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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]; + + +var f = async function*([x, y, z] = [1, 2, 3]) { + +}; + +assert.throws(TypeError, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-init-iter-get-err.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-init-iter-get-err.js new file mode 100644 index 0000000000..7417c77482 --- /dev/null +++ b/js/src/tests/test262/language/expressions/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-expr-dflt.template +/*--- +description: Abrupt completion returned by GetIterator (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [Symbol.iterator, async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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(); +}; + + +var f = async function*([x] = iter) { + +}; + +assert.throws(Test262Error, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-init-iter-no-close.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-init-iter-no-close.js new file mode 100644 index 0000000000..833b9ce498 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-init-iter-no-close.js @@ -0,0 +1,54 @@ +// |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-expr-dflt.template +/*--- +description: Iterator is not closed when exhausted by pattern evaluation (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([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/expressions/async-generator/dstr/dflt-ary-name-iter-val.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-name-iter-val.js new file mode 100644 index 0000000000..a3fb0f3f8d --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-name-iter-val.js @@ -0,0 +1,53 @@ +// |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-expr-dflt.template +/*--- +description: SingleNameBinding with normal value iteration (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([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/expressions/async-generator/dstr/dflt-ary-ptrn-elem-ary-elem-init.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-ary-elem-init.js new file mode 100644 index 0000000000..9fbd8e825d --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-ary-elem-init.js @@ -0,0 +1,45 @@ +// |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-expr-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([[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/expressions/async-generator/dstr/dflt-ary-ptrn-elem-ary-elem-iter.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-ary-elem-iter.js new file mode 100644 index 0000000000..c87c1468e7 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-ary-elem-iter.js @@ -0,0 +1,46 @@ +// |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-expr-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([[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/expressions/async-generator/dstr/dflt-ary-ptrn-elem-ary-elision-init.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-ary-elision-init.js new file mode 100644 index 0000000000..e054192528 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-ary-elision-init.js @@ -0,0 +1,52 @@ +// |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-expr-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([[,] = 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/expressions/async-generator/dstr/dflt-ary-ptrn-elem-ary-elision-iter.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-ary-elision-iter.js new file mode 100644 index 0000000000..b4f6260d6b --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-ary-elision-iter.js @@ -0,0 +1,49 @@ +// |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-expr-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([[,] = 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/expressions/async-generator/dstr/dflt-ary-ptrn-elem-ary-empty-init.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-ary-empty-init.js new file mode 100644 index 0000000000..b7975f6bb1 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-ary-empty-init.js @@ -0,0 +1,48 @@ +// |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-expr-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([[] = 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/expressions/async-generator/dstr/dflt-ary-ptrn-elem-ary-empty-iter.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-ary-empty-iter.js new file mode 100644 index 0000000000..0a81ca4b2b --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-ary-empty-iter.js @@ -0,0 +1,45 @@ +// |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-expr-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([[] = 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/expressions/async-generator/dstr/dflt-ary-ptrn-elem-ary-rest-init.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-ary-rest-init.js new file mode 100644 index 0000000000..249d5d653b --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-ary-rest-init.js @@ -0,0 +1,49 @@ +// |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-expr-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([[...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/expressions/async-generator/dstr/dflt-ary-ptrn-elem-ary-rest-iter.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-ary-rest-iter.js new file mode 100644 index 0000000000..4830799cde --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-ary-rest-iter.js @@ -0,0 +1,52 @@ +// |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-expr-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([[...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/expressions/async-generator/dstr/dflt-ary-ptrn-elem-ary-val-null.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000..352174e9de --- /dev/null +++ b/js/src/tests/test262/language/expressions/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-expr-dflt.template +/*--- +description: Nested array destructuring with a null value (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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). +---*/ + + +var f = async function*([[x]] = [null]) { + +}; + +assert.throws(TypeError, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-id-init-exhausted.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-id-init-exhausted.js new file mode 100644 index 0000000000..f31c183bc3 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-id-init-exhausted.js @@ -0,0 +1,44 @@ +// |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-expr-dflt.template +/*--- +description: Destructuring initializer with an exhausted iterator (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([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/expressions/async-generator/dstr/dflt-ary-ptrn-elem-id-init-fn-name-arrow.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..2f076685d6 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-id-init-fn-name-arrow.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-arrow.case +// - src/dstr-binding/default/async-gen-func-expr-dflt.template +/*--- +description: SingleNameBinding does assign name to arrow functions (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([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/expressions/async-generator/dstr/dflt-ary-ptrn-elem-id-init-fn-name-class.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-id-init-fn-name-class.js new file mode 100644 index 0000000000..2dabdf4fdd --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-id-init-fn-name-class.js @@ -0,0 +1,47 @@ +// |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-expr-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([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/expressions/async-generator/dstr/dflt-ary-ptrn-elem-id-init-fn-name-cover.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-id-init-fn-name-cover.js new file mode 100644 index 0000000000..9f18d946c0 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-id-init-fn-name-cover.js @@ -0,0 +1,46 @@ +// |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-expr-dflt.template +/*--- +description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([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/expressions/async-generator/dstr/dflt-ary-ptrn-elem-id-init-fn-name-fn.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-id-init-fn-name-fn.js new file mode 100644 index 0000000000..e4a6dcf9f5 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-id-init-fn-name-fn.js @@ -0,0 +1,46 @@ +// |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-expr-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([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/expressions/async-generator/dstr/dflt-ary-ptrn-elem-id-init-fn-name-gen.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-id-init-fn-name-gen.js new file mode 100644 index 0000000000..39bae4bba0 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-id-init-fn-name-gen.js @@ -0,0 +1,47 @@ +// |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-expr-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([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/expressions/async-generator/dstr/dflt-ary-ptrn-elem-id-init-hole.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-id-init-hole.js new file mode 100644 index 0000000000..5bfaec83aa --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-id-init-hole.js @@ -0,0 +1,40 @@ +// |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-expr-dflt.template +/*--- +description: Destructuring initializer with a "hole" (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([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/expressions/async-generator/dstr/dflt-ary-ptrn-elem-id-init-skipped.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-id-init-skipped.js new file mode 100644 index 0000000000..b59d4d5ba8 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-id-init-skipped.js @@ -0,0 +1,49 @@ +// |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-expr-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([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/expressions/async-generator/dstr/dflt-ary-ptrn-elem-id-init-throws.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000..5beda66084 --- /dev/null +++ b/js/src/tests/test262/language/expressions/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-expr-dflt.template +/*--- +description: Destructuring initializer returns an abrupt completion (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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). +---*/ + + +var f = async function*([x = (function() { throw new Test262Error(); })()] = [undefined]) { + +}; + +assert.throws(Test262Error, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-id-init-undef.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-id-init-undef.js new file mode 100644 index 0000000000..e96638c874 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-id-init-undef.js @@ -0,0 +1,43 @@ +// |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-expr-dflt.template +/*--- +description: Destructuring initializer with an undefined value (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([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/expressions/async-generator/dstr/dflt-ary-ptrn-elem-id-init-unresolvable.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000..fd29d3b01b --- /dev/null +++ b/js/src/tests/test262/language/expressions/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-expr-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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. +---*/ + + +var f = async function*([ x = unresolvableReference ] = []) { + +}; + +assert.throws(ReferenceError, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-id-iter-complete.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-id-iter-complete.js new file mode 100644 index 0000000000..ea8476aff7 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-id-iter-complete.js @@ -0,0 +1,47 @@ +// |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-expr-dflt.template +/*--- +description: SingleNameBinding when value iteration completes (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([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/expressions/async-generator/dstr/dflt-ary-ptrn-elem-id-iter-done.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-id-iter-done.js new file mode 100644 index 0000000000..0395e46437 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-id-iter-done.js @@ -0,0 +1,42 @@ +// |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-expr-dflt.template +/*--- +description: SingleNameBinding when value iteration was completed previously (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([_, 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/expressions/async-generator/dstr/dflt-ary-ptrn-elem-id-iter-step-err.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000..917f389418 --- /dev/null +++ b/js/src/tests/test262/language/expressions/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-expr-dflt.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [Symbol.iterator, async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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(); + } + }; +}; + + +var f = async function*([x] = g) { + +}; + +assert.throws(Test262Error, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-id-iter-val-array-prototype.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-id-iter-val-array-prototype.js new file mode 100644 index 0000000000..c108a49d6a --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-id-iter-val-array-prototype.js @@ -0,0 +1,63 @@ +// |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-expr-dflt.template +/*--- +description: Array destructuring uses overriden Array.prototype[Symbol.iterator] (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [Symbol.iterator, generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([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/expressions/async-generator/dstr/dflt-ary-ptrn-elem-id-iter-val-err.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000..cf7f43d642 --- /dev/null +++ b/js/src/tests/test262/language/expressions/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-expr-dflt.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [Symbol.iterator, async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; + } + }; +}; + + +var f = async function*([x] = g) { + +}; + +assert.throws(Test262Error, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-id-iter-val.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-id-iter-val.js new file mode 100644 index 0000000000..7547df9678 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-id-iter-val.js @@ -0,0 +1,53 @@ +// |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-expr-dflt.template +/*--- +description: SingleNameBinding when value iteration was completed previously (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([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/expressions/async-generator/dstr/dflt-ary-ptrn-elem-obj-id-init.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-obj-id-init.js new file mode 100644 index 0000000000..2a7e7c918c --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-obj-id-init.js @@ -0,0 +1,45 @@ +// |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-expr-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is used (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([{ 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/expressions/async-generator/dstr/dflt-ary-ptrn-elem-obj-id.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-obj-id.js new file mode 100644 index 0000000000..9d701d0cb9 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-obj-id.js @@ -0,0 +1,45 @@ +// |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-expr-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([{ 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/expressions/async-generator/dstr/dflt-ary-ptrn-elem-obj-prop-id-init.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-obj-prop-id-init.js new file mode 100644 index 0000000000..39aaac977f --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-obj-prop-id-init.js @@ -0,0 +1,55 @@ +// |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-expr-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is used (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([{ 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/expressions/async-generator/dstr/dflt-ary-ptrn-elem-obj-prop-id.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-obj-prop-id.js new file mode 100644 index 0000000000..8b50023295 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-obj-prop-id.js @@ -0,0 +1,55 @@ +// |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-expr-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([{ 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/expressions/async-generator/dstr/dflt-ary-ptrn-elem-obj-val-null.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000..d92839c0af --- /dev/null +++ b/js/src/tests/test262/language/expressions/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-expr-dflt.template +/*--- +description: Nested object destructuring with a null value (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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). +---*/ + + +var f = async function*([{ x }] = [null]) { + +}; + +assert.throws(TypeError, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-obj-val-undef.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000..23f9e50f42 --- /dev/null +++ b/js/src/tests/test262/language/expressions/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-expr-dflt.template +/*--- +description: Nested object destructuring with a value of `undefined` (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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). +---*/ + + +var f = async function*([{ x }] = []) { + +}; + +assert.throws(TypeError, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-elision-exhausted.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-elision-exhausted.js new file mode 100644 index 0000000000..23d7f11e35 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-elision-exhausted.js @@ -0,0 +1,50 @@ +// |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-expr-dflt.template +/*--- +description: Elision accepts exhausted iterator (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([,] = 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/expressions/async-generator/dstr/dflt-ary-ptrn-elision-step-err.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000..91af3f4a52 --- /dev/null +++ b/js/src/tests/test262/language/expressions/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-expr-dflt.template +/*--- +description: Elision advances iterator and forwards abrupt completions (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [generators, async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +}(); + + +var f = async function*([,] = 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/expressions/async-generator/dstr/dflt-ary-ptrn-elision.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-elision.js new file mode 100644 index 0000000000..e3030c6fff --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-elision.js @@ -0,0 +1,59 @@ +// |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-expr-dflt.template +/*--- +description: Elision advances iterator (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([,] = 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/expressions/async-generator/dstr/dflt-ary-ptrn-empty.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-empty.js new file mode 100644 index 0000000000..c13d5103a5 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-empty.js @@ -0,0 +1,42 @@ +// |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-expr-dflt.template +/*--- +description: No iteration occurs for an "empty" array binding pattern (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([] = 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/expressions/async-generator/dstr/dflt-ary-ptrn-rest-ary-elem.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-rest-ary-elem.js new file mode 100644 index 0000000000..fe32d9fec0 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-rest-ary-elem.js @@ -0,0 +1,66 @@ +// |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-expr-dflt.template +/*--- +description: Rest element containing an array BindingElementList pattern (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([...[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/expressions/async-generator/dstr/dflt-ary-ptrn-rest-ary-elision.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-rest-ary-elision.js new file mode 100644 index 0000000000..c8fc278a84 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-rest-ary-elision.js @@ -0,0 +1,72 @@ +// |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-expr-dflt.template +/*--- +description: Rest element containing an elision (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([...[,]] = 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/expressions/async-generator/dstr/dflt-ary-ptrn-rest-ary-empty.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-rest-ary-empty.js new file mode 100644 index 0000000000..fb0cd86521 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-rest-ary-empty.js @@ -0,0 +1,55 @@ +// |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-expr-dflt.template +/*--- +description: Rest element containing an "empty" array pattern (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([...[]] = 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/expressions/async-generator/dstr/dflt-ary-ptrn-rest-ary-rest.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-rest-ary-rest.js new file mode 100644 index 0000000000..0d5caadf49 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-rest-ary-rest.js @@ -0,0 +1,51 @@ +// |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-expr-dflt.template +/*--- +description: Rest element containing a rest element (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([...[...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/expressions/async-generator/dstr/dflt-ary-ptrn-rest-id-direct.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-rest-id-direct.js new file mode 100644 index 0000000000..5eae1b6f9f --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-rest-id-direct.js @@ -0,0 +1,46 @@ +// |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-expr-dflt.template +/*--- +description: Lone rest element (direct binding) (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +includes: [compareArray.js] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([...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/expressions/async-generator/dstr/dflt-ary-ptrn-rest-id-elision-next-err.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000..aef4362e8b --- /dev/null +++ b/js/src/tests/test262/language/expressions/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-expr-dflt.template +/*--- +description: Rest element following elision elements (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [generators, async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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(); })(); + + +var f = async function*([, ...x] = iter) { + +}; + +assert.throws(Test262Error, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-rest-id-elision.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-rest-id-elision.js new file mode 100644 index 0000000000..5c540ce210 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-rest-id-elision.js @@ -0,0 +1,47 @@ +// |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-expr-dflt.template +/*--- +description: Rest element following elision elements (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([ , , ...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/expressions/async-generator/dstr/dflt-ary-ptrn-rest-id-exhausted.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-rest-id-exhausted.js new file mode 100644 index 0000000000..b5ed8bba94 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-rest-id-exhausted.js @@ -0,0 +1,43 @@ +// |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-expr-dflt.template +/*--- +description: RestElement applied to an exhausted iterator (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([, , ...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/expressions/async-generator/dstr/dflt-ary-ptrn-rest-id-iter-step-err.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000..7ca7b599e0 --- /dev/null +++ b/js/src/tests/test262/language/expressions/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-expr-dflt.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [generators, async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +}(); + + +var f = async function*([...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/expressions/async-generator/dstr/dflt-ary-ptrn-rest-id-iter-val-err.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000..2ddd428cc7 --- /dev/null +++ b/js/src/tests/test262/language/expressions/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-expr-dflt.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [Symbol.iterator, async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; + } + }; +}; + + +var f = async function*([...x] = iter) { + +}; + +assert.throws(Test262Error, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-rest-id.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-rest-id.js new file mode 100644 index 0000000000..6c7eba3136 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-rest-id.js @@ -0,0 +1,44 @@ +// |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-expr-dflt.template +/*--- +description: Lone rest element (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([...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/expressions/async-generator/dstr/dflt-ary-ptrn-rest-init-ary.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-rest-init-ary.js new file mode 100644 index 0000000000..315022bdb1 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-rest-init-ary.js @@ -0,0 +1,41 @@ +// |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-expr-dflt.template +/*--- +description: Rest element (nested array pattern) does not support initializer (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async 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/expressions/async-generator/dstr/dflt-ary-ptrn-rest-init-id.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-rest-init-id.js new file mode 100644 index 0000000000..629a101ae8 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-rest-init-id.js @@ -0,0 +1,41 @@ +// |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-expr-dflt.template +/*--- +description: Rest element (identifier) does not support initializer (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async 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/expressions/async-generator/dstr/dflt-ary-ptrn-rest-init-obj.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-rest-init-obj.js new file mode 100644 index 0000000000..e8a3d00057 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-rest-init-obj.js @@ -0,0 +1,41 @@ +// |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-expr-dflt.template +/*--- +description: Rest element (nested object pattern) does not support initializer (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async 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/expressions/async-generator/dstr/dflt-ary-ptrn-rest-not-final-ary.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-rest-not-final-ary.js new file mode 100644 index 0000000000..1aa8204c80 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-rest-not-final-ary.js @@ -0,0 +1,41 @@ +// |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-expr-dflt.template +/*--- +description: Rest element (array binding pattern) may not be followed by any element (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([...[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/expressions/async-generator/dstr/dflt-ary-ptrn-rest-not-final-id.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-rest-not-final-id.js new file mode 100644 index 0000000000..53775afec8 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-rest-not-final-id.js @@ -0,0 +1,41 @@ +// |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-expr-dflt.template +/*--- +description: Rest element (identifier) may not be followed by any element (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([...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/expressions/async-generator/dstr/dflt-ary-ptrn-rest-not-final-obj.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-rest-not-final-obj.js new file mode 100644 index 0000000000..126f67faf2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-rest-not-final-obj.js @@ -0,0 +1,41 @@ +// |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-expr-dflt.template +/*--- +description: Rest element (object binding pattern) may not be followed by any element (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([...{ 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/expressions/async-generator/dstr/dflt-ary-ptrn-rest-obj-id.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-rest-obj-id.js new file mode 100644 index 0000000000..78bb3714df --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-rest-obj-id.js @@ -0,0 +1,44 @@ +// |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-expr-dflt.template +/*--- +description: Rest element containing an object binding pattern (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([...{ 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/expressions/async-generator/dstr/dflt-ary-ptrn-rest-obj-prop-id.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-rest-obj-prop-id.js new file mode 100644 index 0000000000..627eb415fd --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-rest-obj-prop-id.js @@ -0,0 +1,51 @@ +// |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-expr-dflt.template +/*--- +description: Rest element containing an object binding pattern (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*([...{ 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/expressions/async-generator/dstr/dflt-obj-init-null.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-obj-init-null.js new file mode 100644 index 0000000000..7dd2ae9189 --- /dev/null +++ b/js/src/tests/test262/language/expressions/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-expr-dflt.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + + +var f = async function*({} = null) { + +}; + +assert.throws(TypeError, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-obj-init-undefined.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-obj-init-undefined.js new file mode 100644 index 0000000000..1a77f81f97 --- /dev/null +++ b/js/src/tests/test262/language/expressions/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-expr-dflt.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + + +var f = async function*({} = undefined) { + +}; + +assert.throws(TypeError, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-obj-ptrn-empty.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-obj-ptrn-empty.js new file mode 100644 index 0000000000..e8bb916fdc --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-obj-ptrn-empty.js @@ -0,0 +1,43 @@ +// |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-expr-dflt.template +/*--- +description: No property access occurs for an "empty" object binding pattern (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*({} = 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/expressions/async-generator/dstr/dflt-obj-ptrn-id-get-value-err.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000..90acbe9178 --- /dev/null +++ b/js/src/tests/test262/language/expressions/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-expr-dflt.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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(); + } +}); + + +var f = async function*({ poisoned } = poisonedProperty) { + +}; + +assert.throws(Test262Error, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-obj-ptrn-id-init-fn-name-arrow.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-obj-ptrn-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..2dfd5f0955 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-obj-ptrn-id-init-fn-name-arrow.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-arrow.case +// - src/dstr-binding/default/async-gen-func-expr-dflt.template +/*--- +description: SingleNameBinding assigns `name` to arrow functions (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*({ 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/expressions/async-generator/dstr/dflt-obj-ptrn-id-init-fn-name-class.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-obj-ptrn-id-init-fn-name-class.js new file mode 100644 index 0000000000..0876058218 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-obj-ptrn-id-init-fn-name-class.js @@ -0,0 +1,46 @@ +// |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-expr-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*({ 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/expressions/async-generator/dstr/dflt-obj-ptrn-id-init-fn-name-cover.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-obj-ptrn-id-init-fn-name-cover.js new file mode 100644 index 0000000000..6336e2f23f --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-obj-ptrn-id-init-fn-name-cover.js @@ -0,0 +1,45 @@ +// |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-expr-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*({ 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/expressions/async-generator/dstr/dflt-obj-ptrn-id-init-fn-name-fn.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-obj-ptrn-id-init-fn-name-fn.js new file mode 100644 index 0000000000..aca89b9fa1 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-obj-ptrn-id-init-fn-name-fn.js @@ -0,0 +1,45 @@ +// |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-expr-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*({ 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/expressions/async-generator/dstr/dflt-obj-ptrn-id-init-fn-name-gen.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-obj-ptrn-id-init-fn-name-gen.js new file mode 100644 index 0000000000..6cb5124175 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-obj-ptrn-id-init-fn-name-gen.js @@ -0,0 +1,46 @@ +// |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-expr-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*({ 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/expressions/async-generator/dstr/dflt-obj-ptrn-id-init-skipped.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-obj-ptrn-id-init-skipped.js new file mode 100644 index 0000000000..b7eb41b496 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-obj-ptrn-id-init-skipped.js @@ -0,0 +1,48 @@ +// |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-expr-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*({ 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/expressions/async-generator/dstr/dflt-obj-ptrn-id-init-throws.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000..125e900d7c --- /dev/null +++ b/js/src/tests/test262/language/expressions/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-expr-dflt.template +/*--- +description: Error thrown when evaluating the initializer (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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(); +} + + +var f = async function*({ x = thrower() } = {}) { + +}; + +assert.throws(Test262Error, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-obj-ptrn-id-init-unresolvable.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000..1157b32783 --- /dev/null +++ b/js/src/tests/test262/language/expressions/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-expr-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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. +---*/ + + +var f = async function*({ x = unresolvableReference } = {}) { + +}; + +assert.throws(ReferenceError, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-obj-ptrn-id-trailing-comma.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-obj-ptrn-id-trailing-comma.js new file mode 100644 index 0000000000..b716aa978d --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-obj-ptrn-id-trailing-comma.js @@ -0,0 +1,38 @@ +// |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-expr-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + + +var callCount = 0; +var f; +f = async function*({ 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/expressions/async-generator/dstr/dflt-obj-ptrn-list-err.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-obj-ptrn-list-err.js new file mode 100644 index 0000000000..4a78e90510 --- /dev/null +++ b/js/src/tests/test262/language/expressions/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-expr-dflt.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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(); +} + + +var f = async function*({ 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/expressions/async-generator/dstr/dflt-obj-ptrn-prop-ary-init.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-obj-ptrn-prop-ary-init.js new file mode 100644 index 0000000000..713379e1a3 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-obj-ptrn-prop-ary-init.js @@ -0,0 +1,47 @@ +// |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-expr-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern using initializer (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*({ 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/expressions/async-generator/dstr/dflt-obj-ptrn-prop-ary-trailing-comma.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-obj-ptrn-prop-ary-trailing-comma.js new file mode 100644 index 0000000000..c9f6024c27 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-obj-ptrn-prop-ary-trailing-comma.js @@ -0,0 +1,38 @@ +// |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-expr-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + + +var callCount = 0; +var f; +f = async function*({ 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/expressions/async-generator/dstr/dflt-obj-ptrn-prop-ary-value-null.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000..f264a3207f --- /dev/null +++ b/js/src/tests/test262/language/expressions/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-expr-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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 f = async function*({ 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/expressions/async-generator/dstr/dflt-obj-ptrn-prop-ary.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-obj-ptrn-prop-ary.js new file mode 100644 index 0000000000..26ccfa962e --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-obj-ptrn-prop-ary.js @@ -0,0 +1,45 @@ +// |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-expr-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern not using initializer (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*({ 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/expressions/async-generator/dstr/dflt-obj-ptrn-prop-eval-err.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000..3833f98795 --- /dev/null +++ b/js/src/tests/test262/language/expressions/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-expr-dflt.template +/*--- +description: Evaluation of property name returns an abrupt completion (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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(); +} + + +var f = async function*({ [thrower()]: x } = {}) { + +}; + +assert.throws(Test262Error, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-obj-ptrn-prop-id-get-value-err.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000..fa06bd0ff5 --- /dev/null +++ b/js/src/tests/test262/language/expressions/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-expr-dflt.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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(); + } +}); + + +var f = async function*({ poisoned: x = ++initEvalCount } = poisonedProperty) { + +}; + +assert.throws(Test262Error, function() { + f(); +}); + +assert.sameValue(initEvalCount, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-obj-ptrn-prop-id-init-skipped.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-obj-ptrn-prop-id-init-skipped.js new file mode 100644 index 0000000000..a365c90c9e --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-obj-ptrn-prop-id-init-skipped.js @@ -0,0 +1,60 @@ +// |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-expr-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*({ 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/expressions/async-generator/dstr/dflt-obj-ptrn-prop-id-init-throws.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000..b1b612b3dc --- /dev/null +++ b/js/src/tests/test262/language/expressions/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-expr-dflt.template +/*--- +description: Error thrown when evaluating the initializer (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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(); +} + + +var f = async function*({ x: y = thrower() } = {}) { + +}; + +assert.throws(Test262Error, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-obj-ptrn-prop-id-init-unresolvable.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000..690abe4d1f --- /dev/null +++ b/js/src/tests/test262/language/expressions/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-expr-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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. +---*/ + + +var f = async function*({ x: y = unresolvableReference } = {}) { + +}; + +assert.throws(ReferenceError, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-obj-ptrn-prop-id-init.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-obj-ptrn-prop-id-init.js new file mode 100644 index 0000000000..9a48e10248 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-obj-ptrn-prop-id-init.js @@ -0,0 +1,41 @@ +// |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-expr-dflt.template +/*--- +description: Binding as specified via property name, identifier, and initializer (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*({ 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/expressions/async-generator/dstr/dflt-obj-ptrn-prop-id-trailing-comma.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-obj-ptrn-prop-id-trailing-comma.js new file mode 100644 index 0000000000..e4f05cae84 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-obj-ptrn-prop-id-trailing-comma.js @@ -0,0 +1,42 @@ +// |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-expr-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + + +var callCount = 0; +var f; +f = async function*({ 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/expressions/async-generator/dstr/dflt-obj-ptrn-prop-id.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-obj-ptrn-prop-id.js new file mode 100644 index 0000000000..2849bf8730 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-obj-ptrn-prop-id.js @@ -0,0 +1,41 @@ +// |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-expr-dflt.template +/*--- +description: Binding as specified via property name and identifier (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*({ 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/expressions/async-generator/dstr/dflt-obj-ptrn-prop-obj-init.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-obj-ptrn-prop-obj-init.js new file mode 100644 index 0000000000..e21ac34081 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-obj-ptrn-prop-obj-init.js @@ -0,0 +1,47 @@ +// |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-expr-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern using initializer (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*({ 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/expressions/async-generator/dstr/dflt-obj-ptrn-prop-obj-value-null.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000..fb94ec3a2a --- /dev/null +++ b/js/src/tests/test262/language/expressions/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-expr-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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 f = async function*({ 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/expressions/async-generator/dstr/dflt-obj-ptrn-prop-obj-value-undef.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000..c34e69dd2d --- /dev/null +++ b/js/src/tests/test262/language/expressions/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-expr-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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 f = async function*({ w: { x, y, z } = undefined } = { }) { + +}; + +assert.throws(TypeError, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-obj-ptrn-prop-obj.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-obj-ptrn-prop-obj.js new file mode 100644 index 0000000000..631967b330 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-obj-ptrn-prop-obj.js @@ -0,0 +1,45 @@ +// |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-expr-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern not using initializer (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*({ 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/expressions/async-generator/dstr/dflt-obj-ptrn-rest-getter.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-obj-ptrn-rest-getter.js new file mode 100644 index 0000000000..a997f2e2e0 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-obj-ptrn-rest-getter.js @@ -0,0 +1,40 @@ +// |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-expr-dflt.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [object-rest, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + +---*/ +var count = 0; + + +var callCount = 0; +var f; +f = async function*({...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/expressions/async-generator/dstr/dflt-obj-ptrn-rest-skip-non-enumerable.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-obj-ptrn-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..da16d35feb --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-obj-ptrn-rest-skip-non-enumerable.js @@ -0,0 +1,48 @@ +// |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-expr-dflt.template +/*--- +description: Rest object doesn't contain non-enumerable properties (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [object-rest, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + +---*/ +var o = {a: 3, b: 4}; +Object.defineProperty(o, "x", { value: 4, enumerable: false }); + + +var callCount = 0; +var f; +f = async function*({...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/expressions/async-generator/dstr/dflt-obj-ptrn-rest-val-obj.js b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-obj-ptrn-rest-val-obj.js new file mode 100644 index 0000000000..1a9fd733fa --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/dflt-obj-ptrn-rest-val-obj.js @@ -0,0 +1,47 @@ +// |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-expr-dflt.template +/*--- +description: Rest object contains just unextracted data (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [object-rest, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + +---*/ + + +var callCount = 0; +var f; +f = async function*({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/expressions/async-generator/dstr/named-ary-init-iter-close.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-init-iter-close.js new file mode 100644 index 0000000000..e643fc2117 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-init-iter-close.js @@ -0,0 +1,54 @@ +// |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-named-expr.template +/*--- +description: Iterator is closed when not exhausted by pattern evaluation (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([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/expressions/async-generator/dstr/named-ary-init-iter-get-err-array-prototype.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-init-iter-get-err-array-prototype.js new file mode 100644 index 0000000000..e61c4f9fb2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-init-iter-get-err-array-prototype.js @@ -0,0 +1,47 @@ +// 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-named-expr.template +/*--- +description: Abrupt completion returned by GetIterator (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [Symbol.iterator, async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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]; + + +var f; +f = async function* g([x, y, z]) { + +}; + +assert.throws(TypeError, function() { + f([1, 2, 3]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-init-iter-get-err.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-init-iter-get-err.js new file mode 100644 index 0000000000..3b1ec476c7 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-init-iter-get-err.js @@ -0,0 +1,41 @@ +// 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-named-expr.template +/*--- +description: Abrupt completion returned by GetIterator (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [Symbol.iterator, async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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(); +}; + + +var f; +f = async function* g([x]) { + +}; + +assert.throws(Test262Error, function() { + f(iter); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-init-iter-no-close.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-init-iter-no-close.js new file mode 100644 index 0000000000..ea245d046b --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-init-iter-no-close.js @@ -0,0 +1,54 @@ +// |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-named-expr.template +/*--- +description: Iterator is not closed when exhausted by pattern evaluation (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([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/expressions/async-generator/dstr/named-ary-name-iter-val.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-name-iter-val.js new file mode 100644 index 0000000000..6d0148d7c8 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-name-iter-val.js @@ -0,0 +1,53 @@ +// |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-named-expr.template +/*--- +description: SingleNameBinding with normal value iteration (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([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/expressions/async-generator/dstr/named-ary-ptrn-elem-ary-elem-init.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-elem-ary-elem-init.js new file mode 100644 index 0000000000..7969a3eca1 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-elem-ary-elem-init.js @@ -0,0 +1,45 @@ +// |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-named-expr.template +/*--- +description: BindingElement with array binding pattern and initializer is used (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([[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/expressions/async-generator/dstr/named-ary-ptrn-elem-ary-elem-iter.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-elem-ary-elem-iter.js new file mode 100644 index 0000000000..3c57987290 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-elem-ary-elem-iter.js @@ -0,0 +1,46 @@ +// |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-named-expr.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([[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/expressions/async-generator/dstr/named-ary-ptrn-elem-ary-elision-init.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-elem-ary-elision-init.js new file mode 100644 index 0000000000..7eee91f03b --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-elem-ary-elision-init.js @@ -0,0 +1,52 @@ +// |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-named-expr.template +/*--- +description: BindingElement with array binding pattern and initializer is used (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([[,] = 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/expressions/async-generator/dstr/named-ary-ptrn-elem-ary-elision-iter.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-elem-ary-elision-iter.js new file mode 100644 index 0000000000..f4e5703efc --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-elem-ary-elision-iter.js @@ -0,0 +1,49 @@ +// |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-named-expr.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([[,] = 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/expressions/async-generator/dstr/named-ary-ptrn-elem-ary-empty-init.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-elem-ary-empty-init.js new file mode 100644 index 0000000000..e2b6dd2eea --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-elem-ary-empty-init.js @@ -0,0 +1,48 @@ +// |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-named-expr.template +/*--- +description: BindingElement with array binding pattern and initializer is used (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([[] = 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/expressions/async-generator/dstr/named-ary-ptrn-elem-ary-empty-iter.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-elem-ary-empty-iter.js new file mode 100644 index 0000000000..1006dd8154 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-elem-ary-empty-iter.js @@ -0,0 +1,45 @@ +// |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-named-expr.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([[] = 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/expressions/async-generator/dstr/named-ary-ptrn-elem-ary-rest-init.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-elem-ary-rest-init.js new file mode 100644 index 0000000000..c60c89885d --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-elem-ary-rest-init.js @@ -0,0 +1,49 @@ +// |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-named-expr.template +/*--- +description: BindingElement with array binding pattern and initializer is used (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([[...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/expressions/async-generator/dstr/named-ary-ptrn-elem-ary-rest-iter.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-elem-ary-rest-iter.js new file mode 100644 index 0000000000..984a15e9fc --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-elem-ary-rest-iter.js @@ -0,0 +1,52 @@ +// |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-named-expr.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([[...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/expressions/async-generator/dstr/named-ary-ptrn-elem-ary-val-null.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000..66409abe80 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,48 @@ +// 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-named-expr.template +/*--- +description: Nested array destructuring with a null value (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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). +---*/ + + +var f; +f = async function* g([[x]]) { + +}; + +assert.throws(TypeError, function() { + f([null]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-elem-id-init-exhausted.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-elem-id-init-exhausted.js new file mode 100644 index 0000000000..8b5f242782 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-elem-id-init-exhausted.js @@ -0,0 +1,44 @@ +// |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-named-expr.template +/*--- +description: Destructuring initializer with an exhausted iterator (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([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/expressions/async-generator/dstr/named-ary-ptrn-elem-id-init-fn-name-arrow.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-elem-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..454e387c90 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-elem-id-init-fn-name-arrow.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-arrow.case +// - src/dstr-binding/default/async-gen-func-named-expr.template +/*--- +description: SingleNameBinding does assign name to arrow functions (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([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/expressions/async-generator/dstr/named-ary-ptrn-elem-id-init-fn-name-class.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-elem-id-init-fn-name-class.js new file mode 100644 index 0000000000..b1d642afd4 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-elem-id-init-fn-name-class.js @@ -0,0 +1,47 @@ +// |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-named-expr.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([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/expressions/async-generator/dstr/named-ary-ptrn-elem-id-init-fn-name-cover.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-elem-id-init-fn-name-cover.js new file mode 100644 index 0000000000..5623c8ad3d --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-elem-id-init-fn-name-cover.js @@ -0,0 +1,46 @@ +// |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-named-expr.template +/*--- +description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([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/expressions/async-generator/dstr/named-ary-ptrn-elem-id-init-fn-name-fn.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-elem-id-init-fn-name-fn.js new file mode 100644 index 0000000000..775f3c884f --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-elem-id-init-fn-name-fn.js @@ -0,0 +1,46 @@ +// |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-named-expr.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([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/expressions/async-generator/dstr/named-ary-ptrn-elem-id-init-fn-name-gen.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-elem-id-init-fn-name-gen.js new file mode 100644 index 0000000000..54a90d2fda --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-elem-id-init-fn-name-gen.js @@ -0,0 +1,47 @@ +// |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-named-expr.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([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/expressions/async-generator/dstr/named-ary-ptrn-elem-id-init-hole.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-elem-id-init-hole.js new file mode 100644 index 0000000000..298b9d26a7 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-elem-id-init-hole.js @@ -0,0 +1,40 @@ +// |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-named-expr.template +/*--- +description: Destructuring initializer with a "hole" (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([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/expressions/async-generator/dstr/named-ary-ptrn-elem-id-init-skipped.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-elem-id-init-skipped.js new file mode 100644 index 0000000000..072a5db935 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-elem-id-init-skipped.js @@ -0,0 +1,49 @@ +// |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-named-expr.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([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/expressions/async-generator/dstr/named-ary-ptrn-elem-id-init-throws.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000..6ca55f47f0 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,39 @@ +// 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-named-expr.template +/*--- +description: Destructuring initializer returns an abrupt completion (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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). +---*/ + + +var f; +f = async function* g([x = (function() { throw new Test262Error(); })()]) { + +}; + +assert.throws(Test262Error, function() { + f([undefined]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-elem-id-init-undef.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-elem-id-init-undef.js new file mode 100644 index 0000000000..0e3fc16ad7 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-elem-id-init-undef.js @@ -0,0 +1,43 @@ +// |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-named-expr.template +/*--- +description: Destructuring initializer with an undefined value (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([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/expressions/async-generator/dstr/named-ary-ptrn-elem-id-init-unresolvable.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000..b872cf8984 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,46 @@ +// 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-named-expr.template +/*--- +description: Destructuring initializer is an unresolvable reference (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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. +---*/ + + +var f; +f = async function* g([ x = unresolvableReference ]) { + +}; + +assert.throws(ReferenceError, function() { + f([]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-elem-id-iter-complete.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-elem-id-iter-complete.js new file mode 100644 index 0000000000..3eb02deb39 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-elem-id-iter-complete.js @@ -0,0 +1,47 @@ +// |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-named-expr.template +/*--- +description: SingleNameBinding when value iteration completes (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([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/expressions/async-generator/dstr/named-ary-ptrn-elem-id-iter-done.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-elem-id-iter-done.js new file mode 100644 index 0000000000..901a1ca51f --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-elem-id-iter-done.js @@ -0,0 +1,42 @@ +// |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-named-expr.template +/*--- +description: SingleNameBinding when value iteration was completed previously (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([_, 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/expressions/async-generator/dstr/named-ary-ptrn-elem-id-iter-step-err.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000..f40fab78f2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,48 @@ +// 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-named-expr.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [Symbol.iterator, async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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(); + } + }; +}; + + +var f; +f = async function* g([x]) { + +}; + +assert.throws(Test262Error, function() { + f(g); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-elem-id-iter-val-array-prototype.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-elem-id-iter-val-array-prototype.js new file mode 100644 index 0000000000..c4fbfc407c --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-elem-id-iter-val-array-prototype.js @@ -0,0 +1,63 @@ +// |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-named-expr.template +/*--- +description: Array destructuring uses overriden Array.prototype[Symbol.iterator] (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [Symbol.iterator, generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([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/expressions/async-generator/dstr/named-ary-ptrn-elem-id-iter-val-err.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000..14b3f231cf --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,59 @@ +// 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-named-expr.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [Symbol.iterator, async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; + } + }; +}; + + +var f; +f = async function* g([x]) { + +}; + +assert.throws(Test262Error, function() { + f(g); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-elem-id-iter-val.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-elem-id-iter-val.js new file mode 100644 index 0000000000..3c34d924ac --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-elem-id-iter-val.js @@ -0,0 +1,53 @@ +// |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-named-expr.template +/*--- +description: SingleNameBinding when value iteration was completed previously (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([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/expressions/async-generator/dstr/named-ary-ptrn-elem-obj-id-init.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-elem-obj-id-init.js new file mode 100644 index 0000000000..7c411d6cb8 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-elem-obj-id-init.js @@ -0,0 +1,45 @@ +// |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-named-expr.template +/*--- +description: BindingElement with object binding pattern and initializer is used (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([{ 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/expressions/async-generator/dstr/named-ary-ptrn-elem-obj-id.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-elem-obj-id.js new file mode 100644 index 0000000000..253bef3b8e --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-elem-obj-id.js @@ -0,0 +1,45 @@ +// |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-named-expr.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([{ 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/expressions/async-generator/dstr/named-ary-ptrn-elem-obj-prop-id-init.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-elem-obj-prop-id-init.js new file mode 100644 index 0000000000..3e4f8eb2d3 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-elem-obj-prop-id-init.js @@ -0,0 +1,55 @@ +// |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-named-expr.template +/*--- +description: BindingElement with object binding pattern and initializer is used (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([{ 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/expressions/async-generator/dstr/named-ary-ptrn-elem-obj-prop-id.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-elem-obj-prop-id.js new file mode 100644 index 0000000000..6b94949151 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-elem-obj-prop-id.js @@ -0,0 +1,55 @@ +// |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-named-expr.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([{ 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/expressions/async-generator/dstr/named-ary-ptrn-elem-obj-val-null.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000..eeb42baac0 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,48 @@ +// 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-named-expr.template +/*--- +description: Nested object destructuring with a null value (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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). +---*/ + + +var f; +f = async function* g([{ x }]) { + +}; + +assert.throws(TypeError, function() { + f([null]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-elem-obj-val-undef.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000..6ecf1380f7 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,48 @@ +// 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-named-expr.template +/*--- +description: Nested object destructuring with a value of `undefined` (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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). +---*/ + + +var f; +f = async function* g([{ x }]) { + +}; + +assert.throws(TypeError, function() { + f([]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-elision-exhausted.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-elision-exhausted.js new file mode 100644 index 0000000000..b286785f7e --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-elision-exhausted.js @@ -0,0 +1,50 @@ +// |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-named-expr.template +/*--- +description: Elision accepts exhausted iterator (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([,]) { + + 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/expressions/async-generator/dstr/named-ary-ptrn-elision-step-err.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000..6436a3ff45 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-elision-step-err.js @@ -0,0 +1,55 @@ +// 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-named-expr.template +/*--- +description: Elision advances iterator and forwards abrupt completions (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [generators, async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +}(); + + +var f; +f = async function* g([,]) { + +}; + +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/expressions/async-generator/dstr/named-ary-ptrn-elision.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-elision.js new file mode 100644 index 0000000000..0a798b1113 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-elision.js @@ -0,0 +1,59 @@ +// |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-named-expr.template +/*--- +description: Elision advances iterator (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([,]) { + 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/expressions/async-generator/dstr/named-ary-ptrn-empty.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-empty.js new file mode 100644 index 0000000000..b064054dea --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-empty.js @@ -0,0 +1,42 @@ +// |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-named-expr.template +/*--- +description: No iteration occurs for an "empty" array binding pattern (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + + +var callCount = 0; +var f; +f = async function* h([]) { + 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/expressions/async-generator/dstr/named-ary-ptrn-rest-ary-elem.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-rest-ary-elem.js new file mode 100644 index 0000000000..4c9774e603 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-rest-ary-elem.js @@ -0,0 +1,66 @@ +// |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-named-expr.template +/*--- +description: Rest element containing an array BindingElementList pattern (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([...[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/expressions/async-generator/dstr/named-ary-ptrn-rest-ary-elision.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-rest-ary-elision.js new file mode 100644 index 0000000000..654351cfce --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-rest-ary-elision.js @@ -0,0 +1,72 @@ +// |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-named-expr.template +/*--- +description: Rest element containing an elision (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([...[,]]) { + 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/expressions/async-generator/dstr/named-ary-ptrn-rest-ary-empty.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-rest-ary-empty.js new file mode 100644 index 0000000000..632010b46c --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-rest-ary-empty.js @@ -0,0 +1,55 @@ +// |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-named-expr.template +/*--- +description: Rest element containing an "empty" array pattern (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([...[]]) { + 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/expressions/async-generator/dstr/named-ary-ptrn-rest-ary-rest.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-rest-ary-rest.js new file mode 100644 index 0000000000..cfb6f46f72 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-rest-ary-rest.js @@ -0,0 +1,51 @@ +// |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-named-expr.template +/*--- +description: Rest element containing a rest element (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([...[...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/expressions/async-generator/dstr/named-ary-ptrn-rest-id-direct.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-rest-id-direct.js new file mode 100644 index 0000000000..701fa07dc9 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-rest-id-direct.js @@ -0,0 +1,46 @@ +// |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-named-expr.template +/*--- +description: Lone rest element (direct binding) (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +includes: [compareArray.js] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([...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/expressions/async-generator/dstr/named-ary-ptrn-rest-id-elision-next-err.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000..e9d1335f5a --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,41 @@ +// 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-named-expr.template +/*--- +description: Rest element following elision elements (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [generators, async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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(); })(); + + +var f; +f = async function* g([, ...x]) { + +}; + +assert.throws(Test262Error, function() { + f(iter); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-rest-id-elision.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-rest-id-elision.js new file mode 100644 index 0000000000..93215c2509 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-rest-id-elision.js @@ -0,0 +1,47 @@ +// |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-named-expr.template +/*--- +description: Rest element following elision elements (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([ , , ...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/expressions/async-generator/dstr/named-ary-ptrn-rest-id-exhausted.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-rest-id-exhausted.js new file mode 100644 index 0000000000..93753206f8 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-rest-id-exhausted.js @@ -0,0 +1,43 @@ +// |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-named-expr.template +/*--- +description: RestElement applied to an exhausted iterator (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([, , ...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/expressions/async-generator/dstr/named-ary-ptrn-rest-id-iter-step-err.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000..2375a3d3f2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,52 @@ +// 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-named-expr.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [generators, async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +}(); + + +var f; +f = async function* g([...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/expressions/async-generator/dstr/named-ary-ptrn-rest-id-iter-val-err.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000..21023db9be --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,54 @@ +// 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-named-expr.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [Symbol.iterator, async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; + } + }; +}; + + +var f; +f = async function* g([...x]) { + +}; + +assert.throws(Test262Error, function() { + f(iter); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-rest-id.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-rest-id.js new file mode 100644 index 0000000000..41a1db43d5 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-rest-id.js @@ -0,0 +1,44 @@ +// |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-named-expr.template +/*--- +description: Lone rest element (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([...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/expressions/async-generator/dstr/named-ary-ptrn-rest-init-ary.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-rest-init-ary.js new file mode 100644 index 0000000000..4e327b7d22 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-rest-init-ary.js @@ -0,0 +1,41 @@ +// |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-named-expr.template +/*--- +description: Rest element (nested array pattern) does not support initializer (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([...[ 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/expressions/async-generator/dstr/named-ary-ptrn-rest-init-id.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-rest-init-id.js new file mode 100644 index 0000000000..2ec762492c --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-rest-init-id.js @@ -0,0 +1,41 @@ +// |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-named-expr.template +/*--- +description: Rest element (identifier) does not support initializer (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([...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/expressions/async-generator/dstr/named-ary-ptrn-rest-init-obj.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-rest-init-obj.js new file mode 100644 index 0000000000..fa7d8d369a --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-rest-init-obj.js @@ -0,0 +1,41 @@ +// |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-named-expr.template +/*--- +description: Rest element (nested object pattern) does not support initializer (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([...{ 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/expressions/async-generator/dstr/named-ary-ptrn-rest-not-final-ary.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-rest-not-final-ary.js new file mode 100644 index 0000000000..582a9482ad --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-rest-not-final-ary.js @@ -0,0 +1,41 @@ +// |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-named-expr.template +/*--- +description: Rest element (array binding pattern) may not be followed by any element (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([...[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/expressions/async-generator/dstr/named-ary-ptrn-rest-not-final-id.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-rest-not-final-id.js new file mode 100644 index 0000000000..6dcef40b7b --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-rest-not-final-id.js @@ -0,0 +1,41 @@ +// |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-named-expr.template +/*--- +description: Rest element (identifier) may not be followed by any element (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([...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/expressions/async-generator/dstr/named-ary-ptrn-rest-not-final-obj.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-rest-not-final-obj.js new file mode 100644 index 0000000000..c82783bab9 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-rest-not-final-obj.js @@ -0,0 +1,41 @@ +// |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-named-expr.template +/*--- +description: Rest element (object binding pattern) may not be followed by any element (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([...{ 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/expressions/async-generator/dstr/named-ary-ptrn-rest-obj-id.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-rest-obj-id.js new file mode 100644 index 0000000000..c9e5949560 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-rest-obj-id.js @@ -0,0 +1,44 @@ +// |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-named-expr.template +/*--- +description: Rest element containing an object binding pattern (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([...{ 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/expressions/async-generator/dstr/named-ary-ptrn-rest-obj-prop-id.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-rest-obj-prop-id.js new file mode 100644 index 0000000000..eeaa2bb073 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-ary-ptrn-rest-obj-prop-id.js @@ -0,0 +1,51 @@ +// |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-named-expr.template +/*--- +description: Rest element containing an object binding pattern (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([...{ 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/expressions/async-generator/dstr/named-dflt-ary-init-iter-close.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-init-iter-close.js new file mode 100644 index 0000000000..97eed460a6 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-init-iter-close.js @@ -0,0 +1,54 @@ +// |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-named-expr-dflt.template +/*--- +description: Iterator is closed when not exhausted by pattern evaluation (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([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/expressions/async-generator/dstr/named-dflt-ary-init-iter-get-err-array-prototype.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-init-iter-get-err-array-prototype.js new file mode 100644 index 0000000000..b1c34faf7f --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-init-iter-get-err-array-prototype.js @@ -0,0 +1,47 @@ +// 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-named-expr-dflt.template +/*--- +description: Abrupt completion returned by GetIterator (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [Symbol.iterator, async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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]; + + +var f; +f = async function* h([x, y, z] = [1, 2, 3]) { + +}; + +assert.throws(TypeError, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-init-iter-get-err.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-init-iter-get-err.js new file mode 100644 index 0000000000..3d2e6d697d --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-init-iter-get-err.js @@ -0,0 +1,41 @@ +// 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-named-expr-dflt.template +/*--- +description: Abrupt completion returned by GetIterator (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [Symbol.iterator, async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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(); +}; + + +var f; +f = async function* h([x] = iter) { + +}; + +assert.throws(Test262Error, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-init-iter-no-close.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-init-iter-no-close.js new file mode 100644 index 0000000000..1312d5b3fd --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-init-iter-no-close.js @@ -0,0 +1,54 @@ +// |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-named-expr-dflt.template +/*--- +description: Iterator is not closed when exhausted by pattern evaluation (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([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/expressions/async-generator/dstr/named-dflt-ary-name-iter-val.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-name-iter-val.js new file mode 100644 index 0000000000..327f9a1b71 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-name-iter-val.js @@ -0,0 +1,53 @@ +// |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-named-expr-dflt.template +/*--- +description: SingleNameBinding with normal value iteration (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([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/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-ary-elem-init.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-ary-elem-init.js new file mode 100644 index 0000000000..1e94865542 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-ary-elem-init.js @@ -0,0 +1,45 @@ +// |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-named-expr-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([[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/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-ary-elem-iter.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-ary-elem-iter.js new file mode 100644 index 0000000000..31c99d280e --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-ary-elem-iter.js @@ -0,0 +1,46 @@ +// |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-named-expr-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([[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/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-ary-elision-init.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-ary-elision-init.js new file mode 100644 index 0000000000..f583d14e65 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-ary-elision-init.js @@ -0,0 +1,52 @@ +// |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-named-expr-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([[,] = 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/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-ary-elision-iter.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-ary-elision-iter.js new file mode 100644 index 0000000000..2ba8f9ff28 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-ary-elision-iter.js @@ -0,0 +1,49 @@ +// |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-named-expr-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([[,] = 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/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-ary-empty-init.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-ary-empty-init.js new file mode 100644 index 0000000000..fee07a23e2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-ary-empty-init.js @@ -0,0 +1,48 @@ +// |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-named-expr-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([[] = 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/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-ary-empty-iter.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-ary-empty-iter.js new file mode 100644 index 0000000000..66fb127397 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-ary-empty-iter.js @@ -0,0 +1,45 @@ +// |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-named-expr-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([[] = 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/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-ary-rest-init.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-ary-rest-init.js new file mode 100644 index 0000000000..c9bb825ff7 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-ary-rest-init.js @@ -0,0 +1,49 @@ +// |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-named-expr-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([[...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/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-ary-rest-iter.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-ary-rest-iter.js new file mode 100644 index 0000000000..bb52e4f49f --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-ary-rest-iter.js @@ -0,0 +1,52 @@ +// |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-named-expr-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([[...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/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-ary-val-null.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000..120c6e76bb --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,48 @@ +// 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-named-expr-dflt.template +/*--- +description: Nested array destructuring with a null value (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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). +---*/ + + +var f; +f = async function* h([[x]] = [null]) { + +}; + +assert.throws(TypeError, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-id-init-exhausted.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-id-init-exhausted.js new file mode 100644 index 0000000000..adeaa103e9 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-id-init-exhausted.js @@ -0,0 +1,44 @@ +// |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-named-expr-dflt.template +/*--- +description: Destructuring initializer with an exhausted iterator (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([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/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..0ac4c493a1 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-id-init-fn-name-arrow.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-arrow.case +// - src/dstr-binding/default/async-gen-func-named-expr-dflt.template +/*--- +description: SingleNameBinding does assign name to arrow functions (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([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/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-id-init-fn-name-class.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-id-init-fn-name-class.js new file mode 100644 index 0000000000..324602ee51 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-id-init-fn-name-class.js @@ -0,0 +1,47 @@ +// |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-named-expr-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([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/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-id-init-fn-name-cover.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-id-init-fn-name-cover.js new file mode 100644 index 0000000000..825c0113fe --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-id-init-fn-name-cover.js @@ -0,0 +1,46 @@ +// |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-named-expr-dflt.template +/*--- +description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([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/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-id-init-fn-name-fn.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-id-init-fn-name-fn.js new file mode 100644 index 0000000000..f0aa5d2090 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-id-init-fn-name-fn.js @@ -0,0 +1,46 @@ +// |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-named-expr-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([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/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-id-init-fn-name-gen.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-id-init-fn-name-gen.js new file mode 100644 index 0000000000..3ce1c5af16 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-id-init-fn-name-gen.js @@ -0,0 +1,47 @@ +// |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-named-expr-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([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/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-id-init-hole.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-id-init-hole.js new file mode 100644 index 0000000000..23a7f9ffd5 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-id-init-hole.js @@ -0,0 +1,40 @@ +// |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-named-expr-dflt.template +/*--- +description: Destructuring initializer with a "hole" (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([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/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-id-init-skipped.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-id-init-skipped.js new file mode 100644 index 0000000000..6542568429 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-id-init-skipped.js @@ -0,0 +1,49 @@ +// |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-named-expr-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([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/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-id-init-throws.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000..2bb0a406b6 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,39 @@ +// 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-named-expr-dflt.template +/*--- +description: Destructuring initializer returns an abrupt completion (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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). +---*/ + + +var f; +f = async function* h([x = (function() { throw new Test262Error(); })()] = [undefined]) { + +}; + +assert.throws(Test262Error, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-id-init-undef.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-id-init-undef.js new file mode 100644 index 0000000000..21afd82d2a --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-id-init-undef.js @@ -0,0 +1,43 @@ +// |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-named-expr-dflt.template +/*--- +description: Destructuring initializer with an undefined value (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([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/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-id-init-unresolvable.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000..71aca3bb97 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,46 @@ +// 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-named-expr-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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. +---*/ + + +var f; +f = async function* h([ x = unresolvableReference ] = []) { + +}; + +assert.throws(ReferenceError, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-id-iter-complete.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-id-iter-complete.js new file mode 100644 index 0000000000..a97fe06963 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-id-iter-complete.js @@ -0,0 +1,47 @@ +// |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-named-expr-dflt.template +/*--- +description: SingleNameBinding when value iteration completes (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([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/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-id-iter-done.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-id-iter-done.js new file mode 100644 index 0000000000..9bbabceafa --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-id-iter-done.js @@ -0,0 +1,42 @@ +// |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-named-expr-dflt.template +/*--- +description: SingleNameBinding when value iteration was completed previously (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([_, 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/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-id-iter-step-err.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000..31842304c2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,48 @@ +// 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-named-expr-dflt.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [Symbol.iterator, async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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(); + } + }; +}; + + +var f; +f = async function* h([x] = g) { + +}; + +assert.throws(Test262Error, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-id-iter-val-array-prototype.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-id-iter-val-array-prototype.js new file mode 100644 index 0000000000..6109699b86 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-id-iter-val-array-prototype.js @@ -0,0 +1,63 @@ +// |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-named-expr-dflt.template +/*--- +description: Array destructuring uses overriden Array.prototype[Symbol.iterator] (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [Symbol.iterator, generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([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/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-id-iter-val-err.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000..3921b1ca21 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,59 @@ +// 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-named-expr-dflt.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [Symbol.iterator, async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; + } + }; +}; + + +var f; +f = async function* h([x] = g) { + +}; + +assert.throws(Test262Error, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-id-iter-val.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-id-iter-val.js new file mode 100644 index 0000000000..81c79b9e7f --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-id-iter-val.js @@ -0,0 +1,53 @@ +// |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-named-expr-dflt.template +/*--- +description: SingleNameBinding when value iteration was completed previously (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([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/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-obj-id-init.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-obj-id-init.js new file mode 100644 index 0000000000..0ea1e5cbad --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-obj-id-init.js @@ -0,0 +1,45 @@ +// |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-named-expr-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is used (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([{ 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/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-obj-id.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-obj-id.js new file mode 100644 index 0000000000..aaa1578190 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-obj-id.js @@ -0,0 +1,45 @@ +// |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-named-expr-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([{ 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/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-obj-prop-id-init.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-obj-prop-id-init.js new file mode 100644 index 0000000000..981296a5d9 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-obj-prop-id-init.js @@ -0,0 +1,55 @@ +// |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-named-expr-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is used (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([{ 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/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-obj-prop-id.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-obj-prop-id.js new file mode 100644 index 0000000000..25e1a68221 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-obj-prop-id.js @@ -0,0 +1,55 @@ +// |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-named-expr-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([{ 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/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-obj-val-null.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000..bfa0bbce60 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,48 @@ +// 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-named-expr-dflt.template +/*--- +description: Nested object destructuring with a null value (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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). +---*/ + + +var f; +f = async function* h([{ x }] = [null]) { + +}; + +assert.throws(TypeError, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-obj-val-undef.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000..bc14482743 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,48 @@ +// 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-named-expr-dflt.template +/*--- +description: Nested object destructuring with a value of `undefined` (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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). +---*/ + + +var f; +f = async function* h([{ x }] = []) { + +}; + +assert.throws(TypeError, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elision-exhausted.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elision-exhausted.js new file mode 100644 index 0000000000..74f6dfb70e --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elision-exhausted.js @@ -0,0 +1,50 @@ +// |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-named-expr-dflt.template +/*--- +description: Elision accepts exhausted iterator (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([,] = 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/expressions/async-generator/dstr/named-dflt-ary-ptrn-elision-step-err.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000..69240fea46 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elision-step-err.js @@ -0,0 +1,55 @@ +// 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-named-expr-dflt.template +/*--- +description: Elision advances iterator and forwards abrupt completions (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [generators, async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +}(); + + +var f; +f = async function* h([,] = 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/expressions/async-generator/dstr/named-dflt-ary-ptrn-elision.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elision.js new file mode 100644 index 0000000000..1d36274ae7 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elision.js @@ -0,0 +1,59 @@ +// |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-named-expr-dflt.template +/*--- +description: Elision advances iterator (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([,] = 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/expressions/async-generator/dstr/named-dflt-ary-ptrn-empty.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-empty.js new file mode 100644 index 0000000000..7aa5bec2a6 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-empty.js @@ -0,0 +1,42 @@ +// |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-named-expr-dflt.template +/*--- +description: No iteration occurs for an "empty" array binding pattern (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + + +var callCount = 0; +var f; +f = async function* h([] = 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/expressions/async-generator/dstr/named-dflt-ary-ptrn-rest-ary-elem.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-rest-ary-elem.js new file mode 100644 index 0000000000..5c7ae5a707 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-rest-ary-elem.js @@ -0,0 +1,66 @@ +// |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-named-expr-dflt.template +/*--- +description: Rest element containing an array BindingElementList pattern (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([...[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/expressions/async-generator/dstr/named-dflt-ary-ptrn-rest-ary-elision.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-rest-ary-elision.js new file mode 100644 index 0000000000..6c0da07989 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-rest-ary-elision.js @@ -0,0 +1,72 @@ +// |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-named-expr-dflt.template +/*--- +description: Rest element containing an elision (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([...[,]] = 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/expressions/async-generator/dstr/named-dflt-ary-ptrn-rest-ary-empty.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-rest-ary-empty.js new file mode 100644 index 0000000000..bf3545990b --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-rest-ary-empty.js @@ -0,0 +1,55 @@ +// |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-named-expr-dflt.template +/*--- +description: Rest element containing an "empty" array pattern (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([...[]] = 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/expressions/async-generator/dstr/named-dflt-ary-ptrn-rest-ary-rest.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-rest-ary-rest.js new file mode 100644 index 0000000000..b589d81032 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-rest-ary-rest.js @@ -0,0 +1,51 @@ +// |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-named-expr-dflt.template +/*--- +description: Rest element containing a rest element (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([...[...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/expressions/async-generator/dstr/named-dflt-ary-ptrn-rest-id-direct.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-rest-id-direct.js new file mode 100644 index 0000000000..75851e9fe4 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-rest-id-direct.js @@ -0,0 +1,46 @@ +// |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-named-expr-dflt.template +/*--- +description: Lone rest element (direct binding) (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +includes: [compareArray.js] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([...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/expressions/async-generator/dstr/named-dflt-ary-ptrn-rest-id-elision-next-err.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000..5ed81cbb24 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,41 @@ +// 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-named-expr-dflt.template +/*--- +description: Rest element following elision elements (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [generators, async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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(); })(); + + +var f; +f = async function* h([, ...x] = iter) { + +}; + +assert.throws(Test262Error, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-rest-id-elision.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-rest-id-elision.js new file mode 100644 index 0000000000..5a2b9ab978 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-rest-id-elision.js @@ -0,0 +1,47 @@ +// |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-named-expr-dflt.template +/*--- +description: Rest element following elision elements (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([ , , ...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/expressions/async-generator/dstr/named-dflt-ary-ptrn-rest-id-exhausted.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-rest-id-exhausted.js new file mode 100644 index 0000000000..fb028857bb --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-rest-id-exhausted.js @@ -0,0 +1,43 @@ +// |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-named-expr-dflt.template +/*--- +description: RestElement applied to an exhausted iterator (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([, , ...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/expressions/async-generator/dstr/named-dflt-ary-ptrn-rest-id-iter-step-err.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000..b3e198190c --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,52 @@ +// 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-named-expr-dflt.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [generators, async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +}(); + + +var f; +f = async function* h([...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/expressions/async-generator/dstr/named-dflt-ary-ptrn-rest-id-iter-val-err.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000..43f6f6a8bf --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,54 @@ +// 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-named-expr-dflt.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [Symbol.iterator, async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; + } + }; +}; + + +var f; +f = async function* h([...x] = iter) { + +}; + +assert.throws(Test262Error, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-rest-id.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-rest-id.js new file mode 100644 index 0000000000..97d6324987 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-rest-id.js @@ -0,0 +1,44 @@ +// |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-named-expr-dflt.template +/*--- +description: Lone rest element (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([...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/expressions/async-generator/dstr/named-dflt-ary-ptrn-rest-init-ary.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-rest-init-ary.js new file mode 100644 index 0000000000..23d0961319 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-rest-init-ary.js @@ -0,0 +1,41 @@ +// |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-named-expr-dflt.template +/*--- +description: Rest element (nested array pattern) does not support initializer (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([...[ 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/expressions/async-generator/dstr/named-dflt-ary-ptrn-rest-init-id.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-rest-init-id.js new file mode 100644 index 0000000000..cf38d6066a --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-rest-init-id.js @@ -0,0 +1,41 @@ +// |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-named-expr-dflt.template +/*--- +description: Rest element (identifier) does not support initializer (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([...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/expressions/async-generator/dstr/named-dflt-ary-ptrn-rest-init-obj.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-rest-init-obj.js new file mode 100644 index 0000000000..beb9a382fc --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-rest-init-obj.js @@ -0,0 +1,41 @@ +// |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-named-expr-dflt.template +/*--- +description: Rest element (nested object pattern) does not support initializer (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([...{ 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/expressions/async-generator/dstr/named-dflt-ary-ptrn-rest-not-final-ary.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-rest-not-final-ary.js new file mode 100644 index 0000000000..a718a00735 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-rest-not-final-ary.js @@ -0,0 +1,41 @@ +// |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-named-expr-dflt.template +/*--- +description: Rest element (array binding pattern) may not be followed by any element (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([...[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/expressions/async-generator/dstr/named-dflt-ary-ptrn-rest-not-final-id.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-rest-not-final-id.js new file mode 100644 index 0000000000..e16a19ebef --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-rest-not-final-id.js @@ -0,0 +1,41 @@ +// |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-named-expr-dflt.template +/*--- +description: Rest element (identifier) may not be followed by any element (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([...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/expressions/async-generator/dstr/named-dflt-ary-ptrn-rest-not-final-obj.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-rest-not-final-obj.js new file mode 100644 index 0000000000..bce88cfda8 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-rest-not-final-obj.js @@ -0,0 +1,41 @@ +// |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-named-expr-dflt.template +/*--- +description: Rest element (object binding pattern) may not be followed by any element (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([...{ 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/expressions/async-generator/dstr/named-dflt-ary-ptrn-rest-obj-id.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-rest-obj-id.js new file mode 100644 index 0000000000..7dab228808 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-rest-obj-id.js @@ -0,0 +1,44 @@ +// |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-named-expr-dflt.template +/*--- +description: Rest element containing an object binding pattern (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([...{ 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/expressions/async-generator/dstr/named-dflt-ary-ptrn-rest-obj-prop-id.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-rest-obj-prop-id.js new file mode 100644 index 0000000000..cf048a14be --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-ary-ptrn-rest-obj-prop-id.js @@ -0,0 +1,51 @@ +// |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-named-expr-dflt.template +/*--- +description: Rest element containing an object binding pattern (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h([...{ 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/expressions/async-generator/dstr/named-dflt-obj-init-null.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-obj-init-null.js new file mode 100644 index 0000000000..bbd8e92f7f --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-obj-init-null.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/async-gen-func-named-expr-dflt.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + + +var f; +f = async function* h({} = null) { + +}; + +assert.throws(TypeError, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-obj-init-undefined.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-obj-init-undefined.js new file mode 100644 index 0000000000..ab1837b703 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-obj-init-undefined.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/async-gen-func-named-expr-dflt.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + + +var f; +f = async function* h({} = undefined) { + +}; + +assert.throws(TypeError, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-obj-ptrn-empty.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-obj-ptrn-empty.js new file mode 100644 index 0000000000..4203ec5310 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-obj-ptrn-empty.js @@ -0,0 +1,43 @@ +// |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-named-expr-dflt.template +/*--- +description: No property access occurs for an "empty" object binding pattern (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ +var accessCount = 0; +var obj = Object.defineProperty({}, 'attr', { + get: function() { + accessCount += 1; + } +}); + + +var callCount = 0; +var f; +f = async function* h({} = 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/expressions/async-generator/dstr/named-dflt-obj-ptrn-id-get-value-err.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000..fedfbe2c13 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-obj-ptrn-id-get-value-err.js @@ -0,0 +1,42 @@ +// 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-named-expr-dflt.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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(); + } +}); + + +var f; +f = async function* h({ poisoned } = poisonedProperty) { + +}; + +assert.throws(Test262Error, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-obj-ptrn-id-init-fn-name-arrow.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-obj-ptrn-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..4f73b0c6b4 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-obj-ptrn-id-init-fn-name-arrow.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-arrow.case +// - src/dstr-binding/default/async-gen-func-named-expr-dflt.template +/*--- +description: SingleNameBinding assigns `name` to arrow functions (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h({ 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/expressions/async-generator/dstr/named-dflt-obj-ptrn-id-init-fn-name-class.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-obj-ptrn-id-init-fn-name-class.js new file mode 100644 index 0000000000..d414404cd6 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-obj-ptrn-id-init-fn-name-class.js @@ -0,0 +1,46 @@ +// |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-named-expr-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h({ 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/expressions/async-generator/dstr/named-dflt-obj-ptrn-id-init-fn-name-cover.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-obj-ptrn-id-init-fn-name-cover.js new file mode 100644 index 0000000000..d78ddc2e04 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-obj-ptrn-id-init-fn-name-cover.js @@ -0,0 +1,45 @@ +// |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-named-expr-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h({ 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/expressions/async-generator/dstr/named-dflt-obj-ptrn-id-init-fn-name-fn.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-obj-ptrn-id-init-fn-name-fn.js new file mode 100644 index 0000000000..26d4ecf6aa --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-obj-ptrn-id-init-fn-name-fn.js @@ -0,0 +1,45 @@ +// |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-named-expr-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h({ 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/expressions/async-generator/dstr/named-dflt-obj-ptrn-id-init-fn-name-gen.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-obj-ptrn-id-init-fn-name-gen.js new file mode 100644 index 0000000000..f96d35b737 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-obj-ptrn-id-init-fn-name-gen.js @@ -0,0 +1,46 @@ +// |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-named-expr-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h({ 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/expressions/async-generator/dstr/named-dflt-obj-ptrn-id-init-skipped.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-obj-ptrn-id-init-skipped.js new file mode 100644 index 0000000000..f64179e602 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-obj-ptrn-id-init-skipped.js @@ -0,0 +1,48 @@ +// |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-named-expr-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h({ 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/expressions/async-generator/dstr/named-dflt-obj-ptrn-id-init-throws.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000..fcefde9ed8 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-obj-ptrn-id-init-throws.js @@ -0,0 +1,42 @@ +// 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-named-expr-dflt.template +/*--- +description: Error thrown when evaluating the initializer (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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(); +} + + +var f; +f = async function* h({ x = thrower() } = {}) { + +}; + +assert.throws(Test262Error, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-obj-ptrn-id-init-unresolvable.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000..49b35989f6 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,46 @@ +// 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-named-expr-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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. +---*/ + + +var f; +f = async function* h({ x = unresolvableReference } = {}) { + +}; + +assert.throws(ReferenceError, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-obj-ptrn-id-trailing-comma.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-obj-ptrn-id-trailing-comma.js new file mode 100644 index 0000000000..a52a41e217 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-obj-ptrn-id-trailing-comma.js @@ -0,0 +1,38 @@ +// |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-named-expr-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + + +var callCount = 0; +var f; +f = async function* h({ 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/expressions/async-generator/dstr/named-dflt-obj-ptrn-list-err.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-obj-ptrn-list-err.js new file mode 100644 index 0000000000..dbc65e4f9d --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-obj-ptrn-list-err.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/async-gen-func-named-expr-dflt.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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(); +} + + +var f; +f = async function* h({ 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/expressions/async-generator/dstr/named-dflt-obj-ptrn-prop-ary-init.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-obj-ptrn-prop-ary-init.js new file mode 100644 index 0000000000..6d8179c8e4 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-obj-ptrn-prop-ary-init.js @@ -0,0 +1,47 @@ +// |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-named-expr-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern using initializer (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h({ 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/expressions/async-generator/dstr/named-dflt-obj-ptrn-prop-ary-trailing-comma.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-obj-ptrn-prop-ary-trailing-comma.js new file mode 100644 index 0000000000..02fd64f2b9 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-obj-ptrn-prop-ary-trailing-comma.js @@ -0,0 +1,38 @@ +// |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-named-expr-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + + +var callCount = 0; +var f; +f = async function* h({ 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/expressions/async-generator/dstr/named-dflt-obj-ptrn-prop-ary-value-null.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000..b3bafbf16e --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,37 @@ +// 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-named-expr-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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 f; +f = async function* h({ 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/expressions/async-generator/dstr/named-dflt-obj-ptrn-prop-ary.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-obj-ptrn-prop-ary.js new file mode 100644 index 0000000000..91e70485c3 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-obj-ptrn-prop-ary.js @@ -0,0 +1,45 @@ +// |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-named-expr-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern not using initializer (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h({ 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/expressions/async-generator/dstr/named-dflt-obj-ptrn-prop-eval-err.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000..28d659c6fe --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-obj-ptrn-prop-eval-err.js @@ -0,0 +1,39 @@ +// 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-named-expr-dflt.template +/*--- +description: Evaluation of property name returns an abrupt completion (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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(); +} + + +var f; +f = async function* h({ [thrower()]: x } = {}) { + +}; + +assert.throws(Test262Error, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-obj-ptrn-prop-id-get-value-err.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000..3111195b04 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,44 @@ +// 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-named-expr-dflt.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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(); + } +}); + + +var f; +f = async function* h({ poisoned: x = ++initEvalCount } = poisonedProperty) { + +}; + +assert.throws(Test262Error, function() { + f(); +}); + +assert.sameValue(initEvalCount, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-obj-ptrn-prop-id-init-skipped.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-obj-ptrn-prop-id-init-skipped.js new file mode 100644 index 0000000000..b5a09de042 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-obj-ptrn-prop-id-init-skipped.js @@ -0,0 +1,60 @@ +// |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-named-expr-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h({ 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/expressions/async-generator/dstr/named-dflt-obj-ptrn-prop-id-init-throws.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000..7320fb73bc --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,42 @@ +// 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-named-expr-dflt.template +/*--- +description: Error thrown when evaluating the initializer (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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(); +} + + +var f; +f = async function* h({ x: y = thrower() } = {}) { + +}; + +assert.throws(Test262Error, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-obj-ptrn-prop-id-init-unresolvable.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000..aee05d469c --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,46 @@ +// 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-named-expr-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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. +---*/ + + +var f; +f = async function* h({ x: y = unresolvableReference } = {}) { + +}; + +assert.throws(ReferenceError, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-obj-ptrn-prop-id-init.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-obj-ptrn-prop-id-init.js new file mode 100644 index 0000000000..c4f79f4ee8 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-obj-ptrn-prop-id-init.js @@ -0,0 +1,41 @@ +// |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-named-expr-dflt.template +/*--- +description: Binding as specified via property name, identifier, and initializer (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +var f; +f = async function* h({ 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/expressions/async-generator/dstr/named-dflt-obj-ptrn-prop-id-trailing-comma.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-obj-ptrn-prop-id-trailing-comma.js new file mode 100644 index 0000000000..d331e19fe6 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-obj-ptrn-prop-id-trailing-comma.js @@ -0,0 +1,42 @@ +// |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-named-expr-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + + +var callCount = 0; +var f; +f = async function* h({ 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/expressions/async-generator/dstr/named-dflt-obj-ptrn-prop-id.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-obj-ptrn-prop-id.js new file mode 100644 index 0000000000..d390aaf442 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-obj-ptrn-prop-id.js @@ -0,0 +1,41 @@ +// |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-named-expr-dflt.template +/*--- +description: Binding as specified via property name and identifier (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +var f; +f = async function* h({ 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/expressions/async-generator/dstr/named-dflt-obj-ptrn-prop-obj-init.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-obj-ptrn-prop-obj-init.js new file mode 100644 index 0000000000..02cb6a3f59 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-obj-ptrn-prop-obj-init.js @@ -0,0 +1,47 @@ +// |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-named-expr-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern using initializer (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h({ 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/expressions/async-generator/dstr/named-dflt-obj-ptrn-prop-obj-value-null.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000..b63dc5ff74 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,37 @@ +// 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-named-expr-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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 f; +f = async function* h({ 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/expressions/async-generator/dstr/named-dflt-obj-ptrn-prop-obj-value-undef.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000..5fb1a5326d --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,37 @@ +// 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-named-expr-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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 f; +f = async function* h({ w: { x, y, z } = undefined } = { }) { + +}; + +assert.throws(TypeError, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-obj-ptrn-prop-obj.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-obj-ptrn-prop-obj.js new file mode 100644 index 0000000000..d7f909c240 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-obj-ptrn-prop-obj.js @@ -0,0 +1,45 @@ +// |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-named-expr-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern not using initializer (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h({ 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/expressions/async-generator/dstr/named-dflt-obj-ptrn-rest-getter.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-obj-ptrn-rest-getter.js new file mode 100644 index 0000000000..835028c927 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-obj-ptrn-rest-getter.js @@ -0,0 +1,40 @@ +// |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-named-expr-dflt.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [object-rest, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + +---*/ +var count = 0; + + +var callCount = 0; +var f; +f = async function* h({...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/expressions/async-generator/dstr/named-dflt-obj-ptrn-rest-skip-non-enumerable.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-obj-ptrn-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..436ad98c52 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-obj-ptrn-rest-skip-non-enumerable.js @@ -0,0 +1,48 @@ +// |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-named-expr-dflt.template +/*--- +description: Rest object doesn't contain non-enumerable properties (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [object-rest, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + +---*/ +var o = {a: 3, b: 4}; +Object.defineProperty(o, "x", { value: 4, enumerable: false }); + + +var callCount = 0; +var f; +f = async function* h({...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/expressions/async-generator/dstr/named-dflt-obj-ptrn-rest-val-obj.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-obj-ptrn-rest-val-obj.js new file mode 100644 index 0000000000..8e3b2d68d9 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-obj-ptrn-rest-val-obj.js @@ -0,0 +1,47 @@ +// |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-named-expr-dflt.template +/*--- +description: Rest object contains just unextracted data (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [object-rest, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + +---*/ + + +var callCount = 0; +var f; +f = async function* h({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/expressions/async-generator/dstr/named-obj-init-null.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-obj-init-null.js new file mode 100644 index 0000000000..b6064a769c --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-obj-init-null.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/async-gen-func-named-expr.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + + +var f; +f = async function* g({}) { + +}; + +assert.throws(TypeError, function() { + f(null); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dstr/named-obj-init-undefined.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-obj-init-undefined.js new file mode 100644 index 0000000000..04aa4f1ad3 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-obj-init-undefined.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/async-gen-func-named-expr.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + + +var f; +f = async function* g({}) { + +}; + +assert.throws(TypeError, function() { + f(undefined); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dstr/named-obj-ptrn-empty.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-obj-ptrn-empty.js new file mode 100644 index 0000000000..272465447b --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-obj-ptrn-empty.js @@ -0,0 +1,43 @@ +// |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-named-expr.template +/*--- +description: No property access occurs for an "empty" object binding pattern (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ +var accessCount = 0; +var obj = Object.defineProperty({}, 'attr', { + get: function() { + accessCount += 1; + } +}); + + +var callCount = 0; +var f; +f = async function* h({}) { + 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/expressions/async-generator/dstr/named-obj-ptrn-id-get-value-err.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000..2ce4f8cb03 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-obj-ptrn-id-get-value-err.js @@ -0,0 +1,42 @@ +// 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-named-expr.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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(); + } +}); + + +var f; +f = async function* g({ poisoned }) { + +}; + +assert.throws(Test262Error, function() { + f(poisonedProperty); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dstr/named-obj-ptrn-id-init-fn-name-arrow.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-obj-ptrn-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..c1b3726490 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-obj-ptrn-id-init-fn-name-arrow.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-arrow.case +// - src/dstr-binding/default/async-gen-func-named-expr.template +/*--- +description: SingleNameBinding assigns `name` to arrow functions (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h({ 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/expressions/async-generator/dstr/named-obj-ptrn-id-init-fn-name-class.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-obj-ptrn-id-init-fn-name-class.js new file mode 100644 index 0000000000..46bd7d576e --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-obj-ptrn-id-init-fn-name-class.js @@ -0,0 +1,46 @@ +// |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-named-expr.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h({ 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/expressions/async-generator/dstr/named-obj-ptrn-id-init-fn-name-cover.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-obj-ptrn-id-init-fn-name-cover.js new file mode 100644 index 0000000000..d5a02c3d37 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-obj-ptrn-id-init-fn-name-cover.js @@ -0,0 +1,45 @@ +// |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-named-expr.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h({ 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/expressions/async-generator/dstr/named-obj-ptrn-id-init-fn-name-fn.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-obj-ptrn-id-init-fn-name-fn.js new file mode 100644 index 0000000000..5f4250b5c5 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-obj-ptrn-id-init-fn-name-fn.js @@ -0,0 +1,45 @@ +// |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-named-expr.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h({ 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/expressions/async-generator/dstr/named-obj-ptrn-id-init-fn-name-gen.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-obj-ptrn-id-init-fn-name-gen.js new file mode 100644 index 0000000000..af3ec9ce67 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-obj-ptrn-id-init-fn-name-gen.js @@ -0,0 +1,46 @@ +// |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-named-expr.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h({ 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/expressions/async-generator/dstr/named-obj-ptrn-id-init-skipped.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-obj-ptrn-id-init-skipped.js new file mode 100644 index 0000000000..47c7d43e89 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-obj-ptrn-id-init-skipped.js @@ -0,0 +1,48 @@ +// |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-named-expr.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h({ 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/expressions/async-generator/dstr/named-obj-ptrn-id-init-throws.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000..c0ca107850 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-obj-ptrn-id-init-throws.js @@ -0,0 +1,42 @@ +// 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-named-expr.template +/*--- +description: Error thrown when evaluating the initializer (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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(); +} + + +var f; +f = async function* g({ x = thrower() }) { + +}; + +assert.throws(Test262Error, function() { + f({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dstr/named-obj-ptrn-id-init-unresolvable.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000..e5744abc21 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,46 @@ +// 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-named-expr.template +/*--- +description: Destructuring initializer is an unresolvable reference (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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. +---*/ + + +var f; +f = async function* g({ x = unresolvableReference }) { + +}; + +assert.throws(ReferenceError, function() { + f({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dstr/named-obj-ptrn-id-trailing-comma.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-obj-ptrn-id-trailing-comma.js new file mode 100644 index 0000000000..44d8dec12d --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-obj-ptrn-id-trailing-comma.js @@ -0,0 +1,38 @@ +// |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-named-expr.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + + +var callCount = 0; +var f; +f = async function* h({ 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/expressions/async-generator/dstr/named-obj-ptrn-list-err.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-obj-ptrn-list-err.js new file mode 100644 index 0000000000..dce2e24d1f --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-obj-ptrn-list-err.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/async-gen-func-named-expr.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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(); +} + + +var f; +f = async function* g({ 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/expressions/async-generator/dstr/named-obj-ptrn-prop-ary-init.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-obj-ptrn-prop-ary-init.js new file mode 100644 index 0000000000..3d70802764 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-obj-ptrn-prop-ary-init.js @@ -0,0 +1,47 @@ +// |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-named-expr.template +/*--- +description: Object binding pattern with "nested" array binding pattern using initializer (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h({ 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/expressions/async-generator/dstr/named-obj-ptrn-prop-ary-trailing-comma.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-obj-ptrn-prop-ary-trailing-comma.js new file mode 100644 index 0000000000..5404707935 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-obj-ptrn-prop-ary-trailing-comma.js @@ -0,0 +1,38 @@ +// |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-named-expr.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + + +var callCount = 0; +var f; +f = async function* h({ 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/expressions/async-generator/dstr/named-obj-ptrn-prop-ary-value-null.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000..1e62e078ff --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,37 @@ +// 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-named-expr.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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 f; +f = async function* g({ 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/expressions/async-generator/dstr/named-obj-ptrn-prop-ary.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-obj-ptrn-prop-ary.js new file mode 100644 index 0000000000..690381f4dd --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-obj-ptrn-prop-ary.js @@ -0,0 +1,45 @@ +// |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-named-expr.template +/*--- +description: Object binding pattern with "nested" array binding pattern not using initializer (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h({ 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/expressions/async-generator/dstr/named-obj-ptrn-prop-eval-err.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000..67697b9b61 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-obj-ptrn-prop-eval-err.js @@ -0,0 +1,39 @@ +// 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-named-expr.template +/*--- +description: Evaluation of property name returns an abrupt completion (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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(); +} + + +var f; +f = async function* g({ [thrower()]: x }) { + +}; + +assert.throws(Test262Error, function() { + f({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dstr/named-obj-ptrn-prop-id-get-value-err.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000..8dc3082a20 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,44 @@ +// 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-named-expr.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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(); + } +}); + + +var f; +f = async function* g({ poisoned: x = ++initEvalCount }) { + +}; + +assert.throws(Test262Error, function() { + f(poisonedProperty); +}); + +assert.sameValue(initEvalCount, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dstr/named-obj-ptrn-prop-id-init-skipped.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-obj-ptrn-prop-id-init-skipped.js new file mode 100644 index 0000000000..4ecda5b046 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-obj-ptrn-prop-id-init-skipped.js @@ -0,0 +1,60 @@ +// |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-named-expr.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h({ 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/expressions/async-generator/dstr/named-obj-ptrn-prop-id-init-throws.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000..b5a8e64958 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,42 @@ +// 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-named-expr.template +/*--- +description: Error thrown when evaluating the initializer (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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(); +} + + +var f; +f = async function* g({ x: y = thrower() }) { + +}; + +assert.throws(Test262Error, function() { + f({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dstr/named-obj-ptrn-prop-id-init-unresolvable.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000..933524d160 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,46 @@ +// 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-named-expr.template +/*--- +description: Destructuring initializer is an unresolvable reference (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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. +---*/ + + +var f; +f = async function* g({ x: y = unresolvableReference }) { + +}; + +assert.throws(ReferenceError, function() { + f({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dstr/named-obj-ptrn-prop-id-init.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-obj-ptrn-prop-id-init.js new file mode 100644 index 0000000000..330c9c31e0 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-obj-ptrn-prop-id-init.js @@ -0,0 +1,41 @@ +// |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-named-expr.template +/*--- +description: Binding as specified via property name, identifier, and initializer (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +var f; +f = async function* h({ 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/expressions/async-generator/dstr/named-obj-ptrn-prop-id-trailing-comma.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-obj-ptrn-prop-id-trailing-comma.js new file mode 100644 index 0000000000..180b8ad3ff --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-obj-ptrn-prop-id-trailing-comma.js @@ -0,0 +1,42 @@ +// |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-named-expr.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + + +var callCount = 0; +var f; +f = async function* h({ 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/expressions/async-generator/dstr/named-obj-ptrn-prop-id.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-obj-ptrn-prop-id.js new file mode 100644 index 0000000000..55a3888db7 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-obj-ptrn-prop-id.js @@ -0,0 +1,41 @@ +// |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-named-expr.template +/*--- +description: Binding as specified via property name and identifier (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +var f; +f = async function* h({ 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/expressions/async-generator/dstr/named-obj-ptrn-prop-obj-init.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-obj-ptrn-prop-obj-init.js new file mode 100644 index 0000000000..a45c18df19 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-obj-ptrn-prop-obj-init.js @@ -0,0 +1,47 @@ +// |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-named-expr.template +/*--- +description: Object binding pattern with "nested" object binding pattern using initializer (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h({ 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/expressions/async-generator/dstr/named-obj-ptrn-prop-obj-value-null.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000..0659e717ab --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,37 @@ +// 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-named-expr.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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 f; +f = async function* g({ 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/expressions/async-generator/dstr/named-obj-ptrn-prop-obj-value-undef.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000..dc7f82ff9c --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,37 @@ +// 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-named-expr.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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 f; +f = async function* g({ w: { x, y, z } = undefined }) { + +}; + +assert.throws(TypeError, function() { + f({ }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dstr/named-obj-ptrn-prop-obj.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-obj-ptrn-prop-obj.js new file mode 100644 index 0000000000..306dab2a35 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-obj-ptrn-prop-obj.js @@ -0,0 +1,45 @@ +// |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-named-expr.template +/*--- +description: Object binding pattern with "nested" object binding pattern not using initializer (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, 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; +var f; +f = async function* h({ 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/expressions/async-generator/dstr/named-obj-ptrn-rest-getter.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-obj-ptrn-rest-getter.js new file mode 100644 index 0000000000..b70ccb3c62 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-obj-ptrn-rest-getter.js @@ -0,0 +1,40 @@ +// |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-named-expr.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [object-rest, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + +---*/ +var count = 0; + + +var callCount = 0; +var f; +f = async function* h({...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/expressions/async-generator/dstr/named-obj-ptrn-rest-skip-non-enumerable.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-obj-ptrn-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..c605036f44 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-obj-ptrn-rest-skip-non-enumerable.js @@ -0,0 +1,48 @@ +// |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-named-expr.template +/*--- +description: Rest object doesn't contain non-enumerable properties (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [object-rest, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + +---*/ +var o = {a: 3, b: 4}; +Object.defineProperty(o, "x", { value: 4, enumerable: false }); + + +var callCount = 0; +var f; +f = async function* h({...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/expressions/async-generator/dstr/named-obj-ptrn-rest-val-obj.js b/js/src/tests/test262/language/expressions/async-generator/dstr/named-obj-ptrn-rest-val-obj.js new file mode 100644 index 0000000000..588fc7aa2e --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/named-obj-ptrn-rest-val-obj.js @@ -0,0 +1,47 @@ +// |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-named-expr.template +/*--- +description: Rest object contains just unextracted data (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [object-rest, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + +---*/ + + +var callCount = 0; +var f; +f = async function* h({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/expressions/async-generator/dstr/obj-init-null.js b/js/src/tests/test262/language/expressions/async-generator/dstr/obj-init-null.js new file mode 100644 index 0000000000..5ee8a4d505 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/obj-init-null.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/async-gen-func-expr.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + + +var f; +f = async function*({}) { + +}; + +assert.throws(TypeError, function() { + f(null); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dstr/obj-init-undefined.js b/js/src/tests/test262/language/expressions/async-generator/dstr/obj-init-undefined.js new file mode 100644 index 0000000000..68a135e842 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/obj-init-undefined.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/async-gen-func-expr.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + + +var f; +f = async function*({}) { + +}; + +assert.throws(TypeError, function() { + f(undefined); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dstr/obj-ptrn-empty.js b/js/src/tests/test262/language/expressions/async-generator/dstr/obj-ptrn-empty.js new file mode 100644 index 0000000000..77f185ecff --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/obj-ptrn-empty.js @@ -0,0 +1,43 @@ +// |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-expr.template +/*--- +description: No property access occurs for an "empty" object binding pattern (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*({}) { + 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/expressions/async-generator/dstr/obj-ptrn-id-get-value-err.js b/js/src/tests/test262/language/expressions/async-generator/dstr/obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000..d258e6ba13 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/obj-ptrn-id-get-value-err.js @@ -0,0 +1,42 @@ +// 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-expr.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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(); + } +}); + + +var f; +f = async function*({ poisoned }) { + +}; + +assert.throws(Test262Error, function() { + f(poisonedProperty); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dstr/obj-ptrn-id-init-fn-name-arrow.js b/js/src/tests/test262/language/expressions/async-generator/dstr/obj-ptrn-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..7fef7c2cfa --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/obj-ptrn-id-init-fn-name-arrow.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-arrow.case +// - src/dstr-binding/default/async-gen-func-expr.template +/*--- +description: SingleNameBinding assigns `name` to arrow functions (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*({ 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/expressions/async-generator/dstr/obj-ptrn-id-init-fn-name-class.js b/js/src/tests/test262/language/expressions/async-generator/dstr/obj-ptrn-id-init-fn-name-class.js new file mode 100644 index 0000000000..58527f2ae2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/obj-ptrn-id-init-fn-name-class.js @@ -0,0 +1,46 @@ +// |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-expr.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*({ 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/expressions/async-generator/dstr/obj-ptrn-id-init-fn-name-cover.js b/js/src/tests/test262/language/expressions/async-generator/dstr/obj-ptrn-id-init-fn-name-cover.js new file mode 100644 index 0000000000..b0f0cfc3c3 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/obj-ptrn-id-init-fn-name-cover.js @@ -0,0 +1,45 @@ +// |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-expr.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*({ 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/expressions/async-generator/dstr/obj-ptrn-id-init-fn-name-fn.js b/js/src/tests/test262/language/expressions/async-generator/dstr/obj-ptrn-id-init-fn-name-fn.js new file mode 100644 index 0000000000..32dcb5b8af --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/obj-ptrn-id-init-fn-name-fn.js @@ -0,0 +1,45 @@ +// |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-expr.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*({ 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/expressions/async-generator/dstr/obj-ptrn-id-init-fn-name-gen.js b/js/src/tests/test262/language/expressions/async-generator/dstr/obj-ptrn-id-init-fn-name-gen.js new file mode 100644 index 0000000000..af444cc6b4 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/obj-ptrn-id-init-fn-name-gen.js @@ -0,0 +1,46 @@ +// |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-expr.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*({ 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/expressions/async-generator/dstr/obj-ptrn-id-init-skipped.js b/js/src/tests/test262/language/expressions/async-generator/dstr/obj-ptrn-id-init-skipped.js new file mode 100644 index 0000000000..3c3c36ac3c --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/obj-ptrn-id-init-skipped.js @@ -0,0 +1,48 @@ +// |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-expr.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*({ 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/expressions/async-generator/dstr/obj-ptrn-id-init-throws.js b/js/src/tests/test262/language/expressions/async-generator/dstr/obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000..21e1b974c2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/obj-ptrn-id-init-throws.js @@ -0,0 +1,42 @@ +// 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-expr.template +/*--- +description: Error thrown when evaluating the initializer (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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(); +} + + +var f; +f = async function*({ x = thrower() }) { + +}; + +assert.throws(Test262Error, function() { + f({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dstr/obj-ptrn-id-init-unresolvable.js b/js/src/tests/test262/language/expressions/async-generator/dstr/obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000..588d2be359 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,46 @@ +// 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-expr.template +/*--- +description: Destructuring initializer is an unresolvable reference (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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. +---*/ + + +var f; +f = async function*({ x = unresolvableReference }) { + +}; + +assert.throws(ReferenceError, function() { + f({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dstr/obj-ptrn-id-trailing-comma.js b/js/src/tests/test262/language/expressions/async-generator/dstr/obj-ptrn-id-trailing-comma.js new file mode 100644 index 0000000000..2b7e794cf6 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/obj-ptrn-id-trailing-comma.js @@ -0,0 +1,38 @@ +// |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-expr.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + + +var callCount = 0; +var f; +f = async function*({ 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/expressions/async-generator/dstr/obj-ptrn-list-err.js b/js/src/tests/test262/language/expressions/async-generator/dstr/obj-ptrn-list-err.js new file mode 100644 index 0000000000..c8f8712f50 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/obj-ptrn-list-err.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/async-gen-func-expr.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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(); +} + + +var f; +f = async function*({ 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/expressions/async-generator/dstr/obj-ptrn-prop-ary-init.js b/js/src/tests/test262/language/expressions/async-generator/dstr/obj-ptrn-prop-ary-init.js new file mode 100644 index 0000000000..57b8569b9f --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/obj-ptrn-prop-ary-init.js @@ -0,0 +1,47 @@ +// |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-expr.template +/*--- +description: Object binding pattern with "nested" array binding pattern using initializer (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*({ 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/expressions/async-generator/dstr/obj-ptrn-prop-ary-trailing-comma.js b/js/src/tests/test262/language/expressions/async-generator/dstr/obj-ptrn-prop-ary-trailing-comma.js new file mode 100644 index 0000000000..4f12609b64 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/obj-ptrn-prop-ary-trailing-comma.js @@ -0,0 +1,38 @@ +// |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-expr.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + + +var callCount = 0; +var f; +f = async function*({ 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/expressions/async-generator/dstr/obj-ptrn-prop-ary-value-null.js b/js/src/tests/test262/language/expressions/async-generator/dstr/obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000..43054ce5d6 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,37 @@ +// 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-expr.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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 f; +f = async function*({ 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/expressions/async-generator/dstr/obj-ptrn-prop-ary.js b/js/src/tests/test262/language/expressions/async-generator/dstr/obj-ptrn-prop-ary.js new file mode 100644 index 0000000000..5716990e0c --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/obj-ptrn-prop-ary.js @@ -0,0 +1,45 @@ +// |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-expr.template +/*--- +description: Object binding pattern with "nested" array binding pattern not using initializer (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*({ 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/expressions/async-generator/dstr/obj-ptrn-prop-eval-err.js b/js/src/tests/test262/language/expressions/async-generator/dstr/obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000..0f52b003a3 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/obj-ptrn-prop-eval-err.js @@ -0,0 +1,39 @@ +// 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-expr.template +/*--- +description: Evaluation of property name returns an abrupt completion (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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(); +} + + +var f; +f = async function*({ [thrower()]: x }) { + +}; + +assert.throws(Test262Error, function() { + f({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dstr/obj-ptrn-prop-id-get-value-err.js b/js/src/tests/test262/language/expressions/async-generator/dstr/obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000..9e249c829b --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,44 @@ +// 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-expr.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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(); + } +}); + + +var f; +f = async function*({ poisoned: x = ++initEvalCount }) { + +}; + +assert.throws(Test262Error, function() { + f(poisonedProperty); +}); + +assert.sameValue(initEvalCount, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dstr/obj-ptrn-prop-id-init-skipped.js b/js/src/tests/test262/language/expressions/async-generator/dstr/obj-ptrn-prop-id-init-skipped.js new file mode 100644 index 0000000000..95ac9fcdf0 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/obj-ptrn-prop-id-init-skipped.js @@ -0,0 +1,60 @@ +// |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-expr.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*({ 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/expressions/async-generator/dstr/obj-ptrn-prop-id-init-throws.js b/js/src/tests/test262/language/expressions/async-generator/dstr/obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000..27cc7c83c3 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,42 @@ +// 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-expr.template +/*--- +description: Error thrown when evaluating the initializer (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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(); +} + + +var f; +f = async function*({ x: y = thrower() }) { + +}; + +assert.throws(Test262Error, function() { + f({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dstr/obj-ptrn-prop-id-init-unresolvable.js b/js/src/tests/test262/language/expressions/async-generator/dstr/obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000..e900051220 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,46 @@ +// 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-expr.template +/*--- +description: Destructuring initializer is an unresolvable reference (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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. +---*/ + + +var f; +f = async function*({ x: y = unresolvableReference }) { + +}; + +assert.throws(ReferenceError, function() { + f({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dstr/obj-ptrn-prop-id-init.js b/js/src/tests/test262/language/expressions/async-generator/dstr/obj-ptrn-prop-id-init.js new file mode 100644 index 0000000000..38fdb10700 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/obj-ptrn-prop-id-init.js @@ -0,0 +1,41 @@ +// |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-expr.template +/*--- +description: Binding as specified via property name, identifier, and initializer (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*({ 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/expressions/async-generator/dstr/obj-ptrn-prop-id-trailing-comma.js b/js/src/tests/test262/language/expressions/async-generator/dstr/obj-ptrn-prop-id-trailing-comma.js new file mode 100644 index 0000000000..2ad14b75bc --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/obj-ptrn-prop-id-trailing-comma.js @@ -0,0 +1,42 @@ +// |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-expr.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + + +var callCount = 0; +var f; +f = async function*({ 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/expressions/async-generator/dstr/obj-ptrn-prop-id.js b/js/src/tests/test262/language/expressions/async-generator/dstr/obj-ptrn-prop-id.js new file mode 100644 index 0000000000..3e3ddef41d --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/obj-ptrn-prop-id.js @@ -0,0 +1,41 @@ +// |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-expr.template +/*--- +description: Binding as specified via property name and identifier (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*({ 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/expressions/async-generator/dstr/obj-ptrn-prop-obj-init.js b/js/src/tests/test262/language/expressions/async-generator/dstr/obj-ptrn-prop-obj-init.js new file mode 100644 index 0000000000..9e44c37e5f --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/obj-ptrn-prop-obj-init.js @@ -0,0 +1,47 @@ +// |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-expr.template +/*--- +description: Object binding pattern with "nested" object binding pattern using initializer (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*({ 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/expressions/async-generator/dstr/obj-ptrn-prop-obj-value-null.js b/js/src/tests/test262/language/expressions/async-generator/dstr/obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000..7d603c62f6 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,37 @@ +// 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-expr.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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 f; +f = async function*({ 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/expressions/async-generator/dstr/obj-ptrn-prop-obj-value-undef.js b/js/src/tests/test262/language/expressions/async-generator/dstr/obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000..ea685e7b2b --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,37 @@ +// 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-expr.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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 f; +f = async function*({ w: { x, y, z } = undefined }) { + +}; + +assert.throws(TypeError, function() { + f({ }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/dstr/obj-ptrn-prop-obj.js b/js/src/tests/test262/language/expressions/async-generator/dstr/obj-ptrn-prop-obj.js new file mode 100644 index 0000000000..2fb16ded2a --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/obj-ptrn-prop-obj.js @@ -0,0 +1,45 @@ +// |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-expr.template +/*--- +description: Object binding pattern with "nested" object binding pattern not using initializer (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure 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; +var f; +f = async function*({ 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/expressions/async-generator/dstr/obj-ptrn-rest-getter.js b/js/src/tests/test262/language/expressions/async-generator/dstr/obj-ptrn-rest-getter.js new file mode 100644 index 0000000000..207ba7de4a --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/obj-ptrn-rest-getter.js @@ -0,0 +1,40 @@ +// |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-expr.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [object-rest, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + +---*/ +var count = 0; + + +var callCount = 0; +var f; +f = async function*({...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/expressions/async-generator/dstr/obj-ptrn-rest-skip-non-enumerable.js b/js/src/tests/test262/language/expressions/async-generator/dstr/obj-ptrn-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..0b2a97f109 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/obj-ptrn-rest-skip-non-enumerable.js @@ -0,0 +1,48 @@ +// |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-expr.template +/*--- +description: Rest object doesn't contain non-enumerable properties (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [object-rest, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + +---*/ +var o = {a: 3, b: 4}; +Object.defineProperty(o, "x", { value: 4, enumerable: false }); + + +var callCount = 0; +var f; +f = async function*({...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/expressions/async-generator/dstr/obj-ptrn-rest-val-obj.js b/js/src/tests/test262/language/expressions/async-generator/dstr/obj-ptrn-rest-val-obj.js new file mode 100644 index 0000000000..fd09928e16 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/obj-ptrn-rest-val-obj.js @@ -0,0 +1,47 @@ +// |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-expr.template +/*--- +description: Rest object contains just unextracted data (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [object-rest, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + +---*/ + + +var callCount = 0; +var f; +f = async function*({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/expressions/async-generator/dstr/shell.js b/js/src/tests/test262/language/expressions/async-generator/dstr/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/dstr/shell.js diff --git a/js/src/tests/test262/language/expressions/async-generator/early-errors-expression-NSPL-with-USD.js b/js/src/tests/test262/language/expressions/async-generator/early-errors-expression-NSPL-with-USD.js new file mode 100644 index 0000000000..f09c58e53e --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/early-errors-expression-NSPL-with-USD.js @@ -0,0 +1,19 @@ +// |reftest| error:SyntaxError +// Copyright 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Caitlin Potter <caitp@igalia.com> +esid: sec-async-generator-function-definitions-static-semantics-early-errors +description: > + It is a Syntax Error if ContainsUseStrict of AsyncGeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. +negative: + phase: parse + type: SyntaxError +features: [async-iteration] +---*/ + +$DONOTEVALUATE(); + +(async function*(x = 1) {"use strict"}); diff --git a/js/src/tests/test262/language/expressions/async-generator/early-errors-expression-arguments-in-formal-parameters-strict.js b/js/src/tests/test262/language/expressions/async-generator/early-errors-expression-arguments-in-formal-parameters-strict.js new file mode 100644 index 0000000000..f6a7b3a300 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/early-errors-expression-arguments-in-formal-parameters-strict.js @@ -0,0 +1,20 @@ +// |reftest| error:SyntaxError +'use strict'; +// Copyright 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Caitlin Potter <caitp@igalia.com> +esid: sec-async-generator-function-definitions-static-semantics-early-errors +description: > + It is a SyntaxError if FormalParameters contains arguments in strict mode. +negative: + phase: parse + type: SyntaxError +flags: [onlyStrict] +features: [async-iteration] +---*/ + +$DONOTEVALUATE(); + +(async function*(arguments) { }); diff --git a/js/src/tests/test262/language/expressions/async-generator/early-errors-expression-await-as-function-binding-identifier.js b/js/src/tests/test262/language/expressions/async-generator/early-errors-expression-await-as-function-binding-identifier.js new file mode 100644 index 0000000000..fc2b60d1f5 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/early-errors-expression-await-as-function-binding-identifier.js @@ -0,0 +1,18 @@ +// |reftest| error:SyntaxError +// Copyright 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Caitlin Potter <caitp@igalia.com> +esid: sec-identifiers-static-semantics-early-errors +description: > + `await` is not a valid BindingIdentifier for AsyncGeneratorExpressions. +negative: + phase: parse + type: SyntaxError +features: [async-iteration] +---*/ + +$DONOTEVALUATE(); + +(async function* await() { }); diff --git a/js/src/tests/test262/language/expressions/async-generator/early-errors-expression-binding-identifier-arguments-strict.js b/js/src/tests/test262/language/expressions/async-generator/early-errors-expression-binding-identifier-arguments-strict.js new file mode 100644 index 0000000000..7f9c53b5ce --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/early-errors-expression-binding-identifier-arguments-strict.js @@ -0,0 +1,21 @@ +// |reftest| error:SyntaxError +'use strict'; +// Copyright 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Caitlin Potter <caitp@igalia.com> +esid: sec-identifiers-static-semantics-early-errors +description: > + If the source code matching this production is strict code, it is a + Syntax Error if BindingIdentifier is the IdentifierName arguments. +negative: + phase: parse + type: SyntaxError +flags: [onlyStrict] +features: [async-iteration] +---*/ + +$DONOTEVALUATE(); + +(async function* arguments() { }); diff --git a/js/src/tests/test262/language/expressions/async-generator/early-errors-expression-binding-identifier-eval-strict.js b/js/src/tests/test262/language/expressions/async-generator/early-errors-expression-binding-identifier-eval-strict.js new file mode 100644 index 0000000000..45a8922d7a --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/early-errors-expression-binding-identifier-eval-strict.js @@ -0,0 +1,21 @@ +// |reftest| error:SyntaxError +'use strict'; +// Copyright 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Caitlin Potter <caitp@igalia.com> +esid: sec-identifiers-static-semantics-early-errors +description: > + If the source code matching this production is strict code, it is a + Syntax Error if BindingIdentifier is the IdentifierName eval. +negative: + phase: parse + type: SyntaxError +flags: [onlyStrict] +features: [async-iteration] +---*/ + +$DONOTEVALUATE(); + +(async function* eval() { }); diff --git a/js/src/tests/test262/language/expressions/async-generator/early-errors-expression-body-contains-super-call.js b/js/src/tests/test262/language/expressions/async-generator/early-errors-expression-body-contains-super-call.js new file mode 100644 index 0000000000..b074cbc7dd --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/early-errors-expression-body-contains-super-call.js @@ -0,0 +1,18 @@ +// |reftest| error:SyntaxError +// Copyright 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Caitlin Potter <caitp@igalia.com> +esid: sec-async-generator-function-definitions-static-semantics-early-errors +description: > + It is a syntax error if AsyncGeneratorBody contains SuperCall is true. +negative: + phase: parse + type: SyntaxError +features: [async-iteration] +---*/ + +$DONOTEVALUATE(); + +(async function*() { super(); }); diff --git a/js/src/tests/test262/language/expressions/async-generator/early-errors-expression-body-contains-super-property.js b/js/src/tests/test262/language/expressions/async-generator/early-errors-expression-body-contains-super-property.js new file mode 100644 index 0000000000..a62022973e --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/early-errors-expression-body-contains-super-property.js @@ -0,0 +1,18 @@ +// |reftest| error:SyntaxError +// Copyright 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Caitlin Potter <caitp@igalia.com> +esid: sec-async-generator-function-definitions-static-semantics-early-errors +description: > + It is a syntax error if AsyncGeneratorBody contains SuperProperty is true. +negative: + phase: parse + type: SyntaxError +features: [async-iteration] +---*/ + +$DONOTEVALUATE(); + +(async function*() { super.prop; }); diff --git a/js/src/tests/test262/language/expressions/async-generator/early-errors-expression-eval-in-formal-parameters-strict.js b/js/src/tests/test262/language/expressions/async-generator/early-errors-expression-eval-in-formal-parameters-strict.js new file mode 100644 index 0000000000..cd5284a157 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/early-errors-expression-eval-in-formal-parameters-strict.js @@ -0,0 +1,20 @@ +// |reftest| error:SyntaxError +'use strict'; +// Copyright 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Caitlin Potter <caitp@igalia.com> +esid: sec-strict-mode-of-ecmascript +description: > + It is a SyntaxError if FormalParameters contains eval in strict mode. +negative: + phase: parse + type: SyntaxError +flags: [onlyStrict] +features: [async-iteration] +---*/ + +$DONOTEVALUATE(); + +(async function*(eval) { }); diff --git a/js/src/tests/test262/language/expressions/async-generator/early-errors-expression-formals-body-duplicate-const.js b/js/src/tests/test262/language/expressions/async-generator/early-errors-expression-formals-body-duplicate-const.js new file mode 100644 index 0000000000..9be10e9601 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/early-errors-expression-formals-body-duplicate-const.js @@ -0,0 +1,22 @@ +// |reftest| error:SyntaxError +// Copyright 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Caitlin Potter <caitp@igalia.com> +esid: sec-async-generator-function-definitions-static-semantics-early-errors +description: > + It is a SyntaxError if BoundNames of FormalParameters also occurs in the + LexicallyDeclaredNames of AsyncFunctionBody +info: | + It is a Syntax Error if any element of the BoundNames of FormalParameters + also occurs in the LexicallyDeclaredNames of GeneratorBody. +negative: + phase: parse + type: SyntaxError +features: [async-iteration] +---*/ + +$DONOTEVALUATE(); + +(async function*(a) { const a = 0; }); diff --git a/js/src/tests/test262/language/expressions/async-generator/early-errors-expression-formals-body-duplicate-let.js b/js/src/tests/test262/language/expressions/async-generator/early-errors-expression-formals-body-duplicate-let.js new file mode 100644 index 0000000000..aea4309f8e --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/early-errors-expression-formals-body-duplicate-let.js @@ -0,0 +1,19 @@ +// |reftest| error:SyntaxError +// Copyright 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Caitlin Potter <caitp@igalia.com> +esid: sec-async-generator-function-definitions-static-semantics-early-errors +description: > + It is a SyntaxError if BoundNames of FormalParameters also occurs in the + LexicallyDeclaredNames of AsyncFunctionBody +negative: + phase: parse + type: SyntaxError +features: [async-iteration] +---*/ + +$DONOTEVALUATE(); + +(async function*(a) { let a; }); diff --git a/js/src/tests/test262/language/expressions/async-generator/early-errors-expression-formals-contains-await-expr.js b/js/src/tests/test262/language/expressions/async-generator/early-errors-expression-formals-contains-await-expr.js new file mode 100644 index 0000000000..5a6677d8e8 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/early-errors-expression-formals-contains-await-expr.js @@ -0,0 +1,18 @@ +// |reftest| error:SyntaxError +// Copyright 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Caitlin Potter <caitp@igalia.com> +esid: sec-async-generator-function-definitions-static-semantics-early-errors +description: > + It is a Syntax Error if FormalParameters Contains AwaitExpression is true. +negative: + phase: parse + type: SyntaxError +features: [async-iteration] +---*/ + +$DONOTEVALUATE(); + +(async function*(x = await 1) { }); diff --git a/js/src/tests/test262/language/expressions/async-generator/early-errors-expression-formals-contains-await.js b/js/src/tests/test262/language/expressions/async-generator/early-errors-expression-formals-contains-await.js new file mode 100644 index 0000000000..9bf880d200 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/early-errors-expression-formals-contains-await.js @@ -0,0 +1,19 @@ +// |reftest| error:SyntaxError +// Copyright 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Caitlin Potter <caitp@igalia.com> +esid: sec-identifiers-static-semantics-early-errors +description: > + `await` is a reserved keyword within async generator function bodies and may + not be used as the binding identifier of a parameter. +negative: + phase: parse + type: SyntaxError +features: [async-iteration] +---*/ + +$DONOTEVALUATE(); + +(async function*(await) { }); diff --git a/js/src/tests/test262/language/expressions/async-generator/early-errors-expression-formals-contains-super-call.js b/js/src/tests/test262/language/expressions/async-generator/early-errors-expression-formals-contains-super-call.js new file mode 100644 index 0000000000..07801e74eb --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/early-errors-expression-formals-contains-super-call.js @@ -0,0 +1,18 @@ +// |reftest| error:SyntaxError +// Copyright 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Caitlin Potter <caitp@igalia.com> +esid: sec-async-generator-function-definitions-static-semantics-early-errors +description: > + It is a syntax error if FormalParameters contains SuperCall is true. +negative: + phase: parse + type: SyntaxError +features: [async-iteration] +---*/ + +$DONOTEVALUATE(); + +(async function*(a = super()) { }); diff --git a/js/src/tests/test262/language/expressions/async-generator/early-errors-expression-formals-contains-super-property.js b/js/src/tests/test262/language/expressions/async-generator/early-errors-expression-formals-contains-super-property.js new file mode 100644 index 0000000000..344914d8d6 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/early-errors-expression-formals-contains-super-property.js @@ -0,0 +1,18 @@ +// |reftest| error:SyntaxError +// Copyright 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Caitlin Potter <caitp@igalia.com> +esid: sec-async-generator-function-definitions-static-semantics-early-errors +description: > + It is a syntax error if FormalParameters contains SuperProperty is true. +negative: + phase: parse + type: SyntaxError +features: [async-iteration] +---*/ + +$DONOTEVALUATE(); + +(async function*(a = super.prop) { }); diff --git a/js/src/tests/test262/language/expressions/async-generator/early-errors-expression-formals-contains-yield-expr.js b/js/src/tests/test262/language/expressions/async-generator/early-errors-expression-formals-contains-yield-expr.js new file mode 100644 index 0000000000..3e24c30203 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/early-errors-expression-formals-contains-yield-expr.js @@ -0,0 +1,18 @@ +// |reftest| error:SyntaxError +// Copyright 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Caitlin Potter <caitp@igalia.com> +esid: sec-async-generator-function-definitions-static-semantics-early-errors +description: > + It is a Syntax Error if FormalParameters Contains YieldExpression is true. +negative: + phase: parse + type: SyntaxError +features: [async-iteration] +---*/ + +$DONOTEVALUATE(); + +(async function*(x = yield) { }); diff --git a/js/src/tests/test262/language/expressions/async-generator/early-errors-expression-formals-contains-yield.js b/js/src/tests/test262/language/expressions/async-generator/early-errors-expression-formals-contains-yield.js new file mode 100644 index 0000000000..e30271bf70 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/early-errors-expression-formals-contains-yield.js @@ -0,0 +1,19 @@ +// |reftest| error:SyntaxError +// Copyright 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Caitlin Potter <caitp@igalia.com> +esid: sec-identifiers-static-semantics-early-errors +description: > + `yield` is a reserved keyword within async generator function bodies and may + not be used as the binding identifier of a parameter. +negative: + phase: parse + type: SyntaxError +features: [async-iteration] +---*/ + +$DONOTEVALUATE(); + +(async function*(yield) { }); diff --git a/js/src/tests/test262/language/expressions/async-generator/early-errors-expression-label-name-await.js b/js/src/tests/test262/language/expressions/async-generator/early-errors-expression-label-name-await.js new file mode 100644 index 0000000000..c19d21c7ce --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/early-errors-expression-label-name-await.js @@ -0,0 +1,25 @@ +// |reftest| error:SyntaxError +// Copyright 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Caitlin Potter <caitp@igalia.com> +esid: sec-identifiers-static-semantics-early-errors +description: > + `await` is a reserved keyword within async generator function bodies and may + not be used as a label. +info: | + BindingIdentifier : await + + It is a Syntax Error if this production has an [Await] parameter. +negative: + phase: parse + type: SyntaxError +features: [async-iteration] +---*/ + +$DONOTEVALUATE(); + +(async function*() { + await: 1; +}); diff --git a/js/src/tests/test262/language/expressions/async-generator/early-errors-expression-label-name-yield.js b/js/src/tests/test262/language/expressions/async-generator/early-errors-expression-label-name-yield.js new file mode 100644 index 0000000000..3565f700f8 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/early-errors-expression-label-name-yield.js @@ -0,0 +1,27 @@ +// |reftest| error:SyntaxError +// Copyright 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Caitlin Potter <caitp@igalia.com> +esid: sec-identifiers-static-semantics-early-errors +description: > + `yield` is a reserved keyword within async generator function bodies and may + not be used as a label. +info: | + BindingIdentifier : Identifier + LabelIdentifier : Identifier + + It is a Syntax Error if this production has an [Await] parameter and + StringValue of Identifier is "await". +negative: + phase: parse + type: SyntaxError +features: [async-iteration] +---*/ + +$DONOTEVALUATE(); + +(async function*() { + yield: 1; +}); diff --git a/js/src/tests/test262/language/expressions/async-generator/early-errors-expression-not-simple-assignment-target.js b/js/src/tests/test262/language/expressions/async-generator/early-errors-expression-not-simple-assignment-target.js new file mode 100644 index 0000000000..7f49ef1285 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/early-errors-expression-not-simple-assignment-target.js @@ -0,0 +1,18 @@ +// |reftest| error:SyntaxError +// Copyright 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Caitlin Potter <caitp@igalia.com> +esid: prod-LeftHandSideExpression +description: > + Async generator function expressions are not a simple assignment target. +negative: + phase: parse + type: SyntaxError +features: [async-iteration] +---*/ + +$DONOTEVALUATE(); + +(async function*() { } = 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/early-errors-expression-yield-as-function-binding-identifier.js b/js/src/tests/test262/language/expressions/async-generator/early-errors-expression-yield-as-function-binding-identifier.js new file mode 100644 index 0000000000..36a3a63894 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/early-errors-expression-yield-as-function-binding-identifier.js @@ -0,0 +1,18 @@ +// |reftest| error:SyntaxError +// Copyright 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Caitlin Potter <caitp@igalia.com> +esid: sec-async-generator-function-definitions-static-semantics-early-errors +description: > + `yield` is not a valid BindingIdentifier for AsyncGeneratorExpressions. +negative: + phase: parse + type: SyntaxError +features: [async-iteration] +---*/ + +$DONOTEVALUATE(); + +(async function* yield() { }); diff --git a/js/src/tests/test262/language/expressions/async-generator/early-errors-expression-yield-star-after-newline.js b/js/src/tests/test262/language/expressions/async-generator/early-errors-expression-yield-star-after-newline.js new file mode 100644 index 0000000000..6867a3aa5b --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/early-errors-expression-yield-star-after-newline.js @@ -0,0 +1,21 @@ +// |reftest| error:SyntaxError +// Copyright 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Caitlin Potter <caitp@igalia.com> +esid: sec-generator-function-definitions +description: > + A newline may not precede the `*` token in a `yield` expression. +negative: + phase: parse + type: SyntaxError +features: [async-iteration] +---*/ + +$DONOTEVALUATE(); + +(async function*() { + yield + * 1; +}); diff --git a/js/src/tests/test262/language/expressions/async-generator/escaped-async.js b/js/src/tests/test262/language/expressions/async-generator/escaped-async.js new file mode 100644 index 0000000000..6d0692ea29 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/escaped-async.js @@ -0,0 +1,25 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-grammar-notation +description: > + The `async` contextual keyword must not contain Unicode escape sequences. +info: | + Terminal symbols are shown + in fixed width font, both in the productions of the grammars and throughout this + specification whenever the text directly refers to such a terminal symbol. These + are to appear in a script exactly as written. All terminal symbol code points + specified in this way are to be understood as the appropriate Unicode code points + from the Basic Latin range, as opposed to any similar-looking code points from + other Unicode ranges. +negative: + phase: parse + type: SyntaxError +features: [async-iteration] +---*/ + +$DONOTEVALUATE(); + +void \u0061sync function* f(){}; diff --git a/js/src/tests/test262/language/expressions/async-generator/eval-body-proto-realm.js b/js/src/tests/test262/language/expressions/async-generator/eval-body-proto-realm.js new file mode 100644 index 0000000000..1c48e3b768 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/eval-body-proto-realm.js @@ -0,0 +1,54 @@ +// Copyright (C) 2019 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-asyncgenerator-definitions-evaluatebody +description: > + Default [[Prototype]] value derived from realm of the async generator function. +info: | + Runtime Semantics: EvaluateBody + + ... + 2. Let generator be ? OrdinaryCreateFromConstructor(functionObject, "%AsyncGeneratorPrototype%", « ... »). + 3. Perform ! AsyncGeneratorStart(generator, FunctionBody). + 4. Return Completion { [[Type]]: return, [[Value]]: generator, [[Target]]: empty }. + + OrdinaryCreateFromConstructor ( constructor, intrinsicDefaultProto [ , internalSlotsList ] ) + + ... + 2. Let proto be ? GetPrototypeFromConstructor(constructor, intrinsicDefaultProto). + 3. Return ObjectCreate(proto, internalSlotsList). + + GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto ) + + ... + 3. Let proto be ? Get(constructor, 'prototype'). + 4. If Type(proto) is not Object, then + a. Let realm be ? GetFunctionRealm(constructor). + b. Set proto to realm's intrinsic object named intrinsicDefaultProto. + 5. Return proto. +features: [async-iteration, cross-realm, Symbol] +---*/ + +var other = $262.createRealm().global; +var fn = other.eval('(0, async function* () {})'); +var AsyncGeneratorPrototype = Object.getPrototypeOf(fn.prototype); + +fn.prototype = undefined; +assert.sameValue(Object.getPrototypeOf(fn()), AsyncGeneratorPrototype, 'fn.prototype is undefined'); + +fn.prototype = null; +assert.sameValue(Object.getPrototypeOf(fn()), AsyncGeneratorPrototype, 'fn.prototype is null'); + +fn.prototype = true; +assert.sameValue(Object.getPrototypeOf(fn()), AsyncGeneratorPrototype, 'fn.prototype is a Boolean'); + +fn.prototype = 'str'; +assert.sameValue(Object.getPrototypeOf(fn()), AsyncGeneratorPrototype, 'fn.prototype is a String'); + +fn.prototype = Symbol(); +assert.sameValue(Object.getPrototypeOf(fn()), AsyncGeneratorPrototype, 'fn.prototype is a Symbol'); + +fn.prototype = 0; +assert.sameValue(Object.getPrototypeOf(fn()), AsyncGeneratorPrototype, 'fn.prototype is a Number'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/eval-var-scope-syntax-err.js b/js/src/tests/test262/language/expressions/async-generator/eval-var-scope-syntax-err.js new file mode 100644 index 0000000000..d157cd3e4b --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/eval-var-scope-syntax-err.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/eval-var-scope-syntax-err.case +// - src/function-forms/error-no-strict/async-gen-func-expr.template +/*--- +description: sloppy direct eval in params introduces var (async generator function expression in sloppy code) +esid: sec-asyncgenerator-definitions-evaluation +features: [default-parameters, async-iteration] +flags: [generated, noStrict] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + + Runtime Semantics: IteratorBindingInitialization + FormalParameter : BindingElement + + 1. Return the result of performing IteratorBindingInitialization for BindingElement with arguments iteratorRecord and environment. + +---*/ + + +var callCount = 0; +var f; +f = async function*(a = eval("var a = 42")) { + + callCount = callCount + 1; +}; + +assert.throws(SyntaxError, function() { + f(); +}); +assert.sameValue(callCount, 0, 'generator function body not evaluated'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/expression-await-as-yield-operand.js b/js/src/tests/test262/language/expressions/async-generator/expression-await-as-yield-operand.js new file mode 100644 index 0000000000..ece1fe83c9 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/expression-await-as-yield-operand.js @@ -0,0 +1,26 @@ +// |reftest| async +// Copyright 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Caitlin Potter <caitp@igalia.com> +esid: sec-generator-function-definitions +description: > + AwaitExpressions are valid operands to yield expressions. +flags: [async] +features: [async-iteration] +---*/ + +var iter = (async function*() { + yield await "a"; +})(); + +iter.next().then(function(result) { + assert.sameValue(result.value, "a", 'First result `value`'); + assert.sameValue(result.done, false, 'First result `done` flag'); +}).then(undefined, $DONE); + +iter.next().then(function(result) { + assert.sameValue(result.value, undefined, 'Second result `value`'); + assert.sameValue(result.done, true, 'Second result `done` flag'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/async-generator/expression-await-promise-as-yield-operand.js b/js/src/tests/test262/language/expressions/async-generator/expression-await-promise-as-yield-operand.js new file mode 100644 index 0000000000..385b014d44 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/expression-await-promise-as-yield-operand.js @@ -0,0 +1,28 @@ +// |reftest| async +// Copyright 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Caitlin Potter <caitp@igalia.com> +esid: sec-generator-function-definitions +description: > + AwaitExpressions are valid operands to yield expressions. +flags: [async] +features: [async-iteration] +---*/ + +var iter = (async function*() { + yield await new Promise(function(resolve) { + resolve("a"); + }); +})(); + +iter.next().then(function(result) { + assert.sameValue(result.value, "a", 'First result `value`'); + assert.sameValue(result.done, false, 'First result `done` flag'); +}).then(undefined, $DONE); + +iter.next().then(function(result) { + assert.sameValue(result.value, undefined, 'Second result `value`'); + assert.sameValue(result.done, true, 'Second result `done` flag'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/async-generator/expression-await-thenable-as-yield-operand.js b/js/src/tests/test262/language/expressions/async-generator/expression-await-thenable-as-yield-operand.js new file mode 100644 index 0000000000..37877d4333 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/expression-await-thenable-as-yield-operand.js @@ -0,0 +1,32 @@ +// |reftest| async +// Copyright 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Caitlin Potter <caitp@igalia.com> +esid: sec-generator-function-definitions +description: > + AwaitExpressions are valid operands to yield expressions. +flags: [async] +features: [async-iteration] +---*/ + +var thenable = { + then: function(resolve, reject) { + resolve("a"); + } +}; + +var iter = (async function*() { + yield await thenable; +})(); + +iter.next().then(function(result) { + assert.sameValue(result.value, "a", 'First result `value`'); + assert.sameValue(result.done, false, 'First result `done` flag'); +}).then(undefined, $DONE); + +iter.next().then(function(result) { + assert.sameValue(result.value, undefined, 'Second result `value`'); + assert.sameValue(result.done, true, 'Second result `done` flag'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/async-generator/expression-yield-as-operand.js b/js/src/tests/test262/language/expressions/async-generator/expression-yield-as-operand.js new file mode 100644 index 0000000000..d64aba1715 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/expression-yield-as-operand.js @@ -0,0 +1,33 @@ +// |reftest| async +// Copyright 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Caitlin Potter <caitp@igalia.com> +esid: sec-generator-function-definitions +description: > + `yield` expressions may be used as the right-hand-side of other `yield` + expressions. +flags: [async] +features: [async-iteration] +---*/ + +var g = async function*() { + yield yield 1; +}; + +var iter = g(); +iter.next().then(function(result) { + assert.sameValue(result.value, 1, 'First result `value`'); + assert.sameValue(result.done, false, 'First result `done` flag'); +}).then(undefined, $DONE); + +iter.next().then(function(result) { + assert.sameValue(result.value, undefined, 'Second result `value`'); + assert.sameValue(result.done, false, 'Second result `done` flag'); +}).then(undefined, $DONE); + +iter.next().then(function(result) { + assert.sameValue(result.value, undefined, 'Third result `value`'); + assert.sameValue(result.done, true, 'Thid result `done` flag'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/async-generator/expression-yield-as-statement.js b/js/src/tests/test262/language/expressions/async-generator/expression-yield-as-statement.js new file mode 100644 index 0000000000..9cff52a2af --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/expression-yield-as-statement.js @@ -0,0 +1,43 @@ +// |reftest| async +// Copyright 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Caitlin Potter <caitp@igalia.com> +esid: sec-generator-function-definitions +description: > + `yield` is a valid statement within async generator function bodies. +flags: [async] +features: [async-iteration] +---*/ + +var g1 = async function*() { yield; }; +var g2 = async function*() { yield 1; }; + +var iter1 = g1(); +iter1.next().then(function(result) { + assert.sameValue( + result.value, undefined, "Without right-hand-side: first result `value`"); + assert.sameValue( + result.done, false, "Without right-hand-side: first result `done` flag"); +}).then(undefined, $DONE); +iter1.next().then(function(result) { + assert.sameValue( + result.value, undefined, "Without right-hand-side: second result `value`"); + assert.sameValue( + result.done, true, "Without right-hand-side: second result `done` flag"); +}).then(undefined, $DONE); + +var iter2 = g2(); +iter2.next().then(function(result) { + assert.sameValue( + result.value, 1, "With right-hand-side: first result `value`"); + assert.sameValue( + result.done, false, "With right-hand-side: first result `done` flag"); +}).then(undefined, $DONE); +iter2.next().then(function(result) { + assert.sameValue( + result.value, undefined, "With right-hand-side: second result `value`"); + assert.sameValue( + result.done, true, "With right-hand-side: second result `done` flag"); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/async-generator/expression-yield-newline.js b/js/src/tests/test262/language/expressions/async-generator/expression-yield-newline.js new file mode 100644 index 0000000000..541f1a862c --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/expression-yield-newline.js @@ -0,0 +1,28 @@ +// |reftest| async +// Copyright 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Caitlin Potter <caitp@igalia.com> +esid: sec-generator-function-definitions +description: > + Newlines terminate `yield` expressions. +flags: [async] +features: [async-iteration] +---*/ + +var g = async function*() { + yield + 1; +}; + +var iter = g(); +iter.next().then(function(result) { + assert.sameValue(result.value, undefined, 'First result `value`'); + assert.sameValue(result.done, false, 'First result `done` flag'); +}).then(undefined, $DONE); + +iter.next().then(function(result) { + assert.sameValue(result.value, undefined, 'Second result `value`'); + assert.sameValue(result.done, true, 'Second result `done` flag'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/async-generator/expression-yield-star-before-newline.js b/js/src/tests/test262/language/expressions/async-generator/expression-yield-star-before-newline.js new file mode 100644 index 0000000000..f5511e44cf --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/expression-yield-star-before-newline.js @@ -0,0 +1,22 @@ +// |reftest| async +// Copyright 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Caitlin Potter <caitp@igalia.com> +esid: sec-generator-function-definitions +description: > + The right-hand side of a `yield *` expression may appear on a new line. +flags: [async] +features: [async-iteration] +---*/ + +var g = async function*() {}; + +(async function*() { + yield* + g(); +})().next().then(function(result) { + assert.sameValue(result.value, undefined); + assert.sameValue(result.done, true); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/async-generator/forbidden-ext/b1/async-gen-func-expr-forbidden-ext-direct-access-prop-arguments.js b/js/src/tests/test262/language/expressions/async-generator/forbidden-ext/b1/async-gen-func-expr-forbidden-ext-direct-access-prop-arguments.js new file mode 100644 index 0000000000..3695816892 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/forbidden-ext/b1/async-gen-func-expr-forbidden-ext-direct-access-prop-arguments.js @@ -0,0 +1,39 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/forbidden-ext-direct-access-prop-arguments.case +// - src/function-forms/forbidden-extensions/bullet-one/async-gen-func-expr.template +/*--- +description: Forbidden extension, f.arguments (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [arrow-function, async-functions, async-iteration] +flags: [generated, noStrict, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + + ECMAScript function objects defined using syntactic constructors in strict mode code must + not be created with own properties named "caller" or "arguments". Such own properties also + must not be created for function objects defined using an ArrowFunction, MethodDefinition, + GeneratorDeclaration, GeneratorExpression, AsyncGeneratorDeclaration, AsyncGeneratorExpression, + ClassDeclaration, ClassExpression, AsyncFunctionDeclaration, AsyncFunctionExpression, or + AsyncArrowFunction regardless of whether the definition is contained in strict mode code. + Built-in functions, strict functions created using the Function constructor, generator functions + created using the Generator constructor, async functions created using the AsyncFunction + constructor, and functions created using the bind method also must not be created with such own + properties. + +---*/ + + +var callCount = 0; +var f; +f = async function*() { + assert.sameValue(f.hasOwnProperty("arguments"), false); + callCount++; +}; + +f().next() + .then(() => { + assert.sameValue(callCount, 1, 'function body evaluated'); + }, $DONE).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/async-generator/forbidden-ext/b1/async-gen-func-expr-forbidden-ext-direct-access-prop-caller.js b/js/src/tests/test262/language/expressions/async-generator/forbidden-ext/b1/async-gen-func-expr-forbidden-ext-direct-access-prop-caller.js new file mode 100644 index 0000000000..4baefa87a8 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/forbidden-ext/b1/async-gen-func-expr-forbidden-ext-direct-access-prop-caller.js @@ -0,0 +1,39 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/forbidden-ext-direct-access-prop-caller.case +// - src/function-forms/forbidden-extensions/bullet-one/async-gen-func-expr.template +/*--- +description: Forbidden extension, o.caller (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [arrow-function, async-functions, async-iteration] +flags: [generated, noStrict, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + + ECMAScript function objects defined using syntactic constructors in strict mode code must + not be created with own properties named "caller" or "arguments". Such own properties also + must not be created for function objects defined using an ArrowFunction, MethodDefinition, + GeneratorDeclaration, GeneratorExpression, AsyncGeneratorDeclaration, AsyncGeneratorExpression, + ClassDeclaration, ClassExpression, AsyncFunctionDeclaration, AsyncFunctionExpression, or + AsyncArrowFunction regardless of whether the definition is contained in strict mode code. + Built-in functions, strict functions created using the Function constructor, generator functions + created using the Generator constructor, async functions created using the AsyncFunction + constructor, and functions created using the bind method also must not be created with such own + properties. + +---*/ + + +var callCount = 0; +var f; +f = async function*() { + assert.sameValue(f.hasOwnProperty("caller"), false); + callCount++; +}; + +f().next() + .then(() => { + assert.sameValue(callCount, 1, 'function body evaluated'); + }, $DONE).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/async-generator/forbidden-ext/b1/async-gen-named-func-expr-forbidden-ext-direct-access-prop-arguments.js b/js/src/tests/test262/language/expressions/async-generator/forbidden-ext/b1/async-gen-named-func-expr-forbidden-ext-direct-access-prop-arguments.js new file mode 100644 index 0000000000..01c75de1b4 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/forbidden-ext/b1/async-gen-named-func-expr-forbidden-ext-direct-access-prop-arguments.js @@ -0,0 +1,39 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/forbidden-ext-direct-access-prop-arguments.case +// - src/function-forms/forbidden-extensions/bullet-one/async-gen-named-func-expr.template +/*--- +description: Forbidden extension, f.arguments (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [arrow-function, async-functions, async-iteration] +flags: [generated, noStrict, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + + ECMAScript function objects defined using syntactic constructors in strict mode code must + not be created with own properties named "caller" or "arguments". Such own properties also + must not be created for function objects defined using an ArrowFunction, MethodDefinition, + GeneratorDeclaration, GeneratorExpression, AsyncGeneratorDeclaration, AsyncGeneratorExpression, + ClassDeclaration, ClassExpression, AsyncFunctionDeclaration, AsyncFunctionExpression, or + AsyncArrowFunction regardless of whether the definition is contained in strict mode code. + Built-in functions, strict functions created using the Function constructor, generator functions + created using the Generator constructor, async functions created using the AsyncFunction + constructor, and functions created using the bind method also must not be created with such own + properties. + +---*/ + + +var callCount = 0; +var f; +f = async function* g() { + assert.sameValue(f.hasOwnProperty("arguments"), false); + callCount++; +}; + +f().next() + .then(() => { + assert.sameValue(callCount, 1, 'function body evaluated'); + }, $DONE).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/async-generator/forbidden-ext/b1/async-gen-named-func-expr-forbidden-ext-direct-access-prop-caller.js b/js/src/tests/test262/language/expressions/async-generator/forbidden-ext/b1/async-gen-named-func-expr-forbidden-ext-direct-access-prop-caller.js new file mode 100644 index 0000000000..939d7cb830 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/forbidden-ext/b1/async-gen-named-func-expr-forbidden-ext-direct-access-prop-caller.js @@ -0,0 +1,39 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/forbidden-ext-direct-access-prop-caller.case +// - src/function-forms/forbidden-extensions/bullet-one/async-gen-named-func-expr.template +/*--- +description: Forbidden extension, o.caller (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [arrow-function, async-functions, async-iteration] +flags: [generated, noStrict, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + + ECMAScript function objects defined using syntactic constructors in strict mode code must + not be created with own properties named "caller" or "arguments". Such own properties also + must not be created for function objects defined using an ArrowFunction, MethodDefinition, + GeneratorDeclaration, GeneratorExpression, AsyncGeneratorDeclaration, AsyncGeneratorExpression, + ClassDeclaration, ClassExpression, AsyncFunctionDeclaration, AsyncFunctionExpression, or + AsyncArrowFunction regardless of whether the definition is contained in strict mode code. + Built-in functions, strict functions created using the Function constructor, generator functions + created using the Generator constructor, async functions created using the AsyncFunction + constructor, and functions created using the bind method also must not be created with such own + properties. + +---*/ + + +var callCount = 0; +var f; +f = async function* g() { + assert.sameValue(f.hasOwnProperty("caller"), false); + callCount++; +}; + +f().next() + .then(() => { + assert.sameValue(callCount, 1, 'function body evaluated'); + }, $DONE).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/async-generator/forbidden-ext/b1/browser.js b/js/src/tests/test262/language/expressions/async-generator/forbidden-ext/b1/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/forbidden-ext/b1/browser.js diff --git a/js/src/tests/test262/language/expressions/async-generator/forbidden-ext/b1/shell.js b/js/src/tests/test262/language/expressions/async-generator/forbidden-ext/b1/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/forbidden-ext/b1/shell.js diff --git a/js/src/tests/test262/language/expressions/async-generator/forbidden-ext/b2/async-gen-func-expr-forbidden-ext-indirect-access-own-prop-caller-get.js b/js/src/tests/test262/language/expressions/async-generator/forbidden-ext/b2/async-gen-func-expr-forbidden-ext-indirect-access-own-prop-caller-get.js new file mode 100644 index 0000000000..3b1af7907a --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/forbidden-ext/b2/async-gen-func-expr-forbidden-ext-indirect-access-own-prop-caller-get.js @@ -0,0 +1,65 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/forbidden-ext-indirect-access-own-prop-caller-get.case +// - src/function-forms/forbidden-extensions/bullet-two/async-gen-func-expr.template +/*--- +description: Forbidden extension, o.caller (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [arrow-function, async-functions, async-iteration] +flags: [generated, noStrict, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + + If an implementation extends any function object with an own property named "caller" the value of + that property, as observed using [[Get]] or [[GetOwnProperty]], must not be a strict function + object. If it is an accessor property, the function that is the value of the property's [[Get]] + attribute must never return a strict function when called. + +---*/ +var CALLER_OWN_PROPERTY_DOES_NOT_EXIST = Symbol(); +function inner() { + // This property may exist, but is forbidden from having a value that is a strict function object + return inner.hasOwnProperty("caller") + ? inner.caller + : CALLER_OWN_PROPERTY_DOES_NOT_EXIST; +} + + +var callCount = 0; +var f; +f = async function*() { + "use strict"; + // This and the following conditional value is set in the test's .case file. + // For every test that has a "true" value here, there is a + // corresponding test that has a "false" value here. + // They are generated from two different case files, which use + // the same templates. + let descriptor = Object.getOwnPropertyDescriptor(inner, "caller"); + if (descriptor && descriptor.configurable && true) { + Object.defineProperty(inner, "caller", {get(){return 1}}); + } + var result = inner(); + if (descriptor && descriptor.configurable && true) { + assert.sameValue(result, 1, 'If this test defined an own "caller" property on the inner function, then it should be accessible and should return the value it was set to.'); + } + // "CALLER_OWN_PROPERTY_DOES_NOT_EXIST" is from + // forbidden-ext-indirect-access-prop-caller.case + // + // If the function object "inner" has an own property + // named "caller", then its value will be returned. + // + // If the function object "inner" DOES NOT have an + // own property named "caller", then the symbol + // CALLER_OWN_PROPERTY_DOES_NOT_EXIST will be returned. + if (result !== CALLER_OWN_PROPERTY_DOES_NOT_EXIST) { + assert.notSameValue(result, f); + } + callCount++; +}; + +f().next() + .then(() => { + assert.sameValue(callCount, 1, 'function body evaluated'); + }, $DONE).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/async-generator/forbidden-ext/b2/async-gen-func-expr-forbidden-ext-indirect-access-own-prop-caller-value.js b/js/src/tests/test262/language/expressions/async-generator/forbidden-ext/b2/async-gen-func-expr-forbidden-ext-indirect-access-own-prop-caller-value.js new file mode 100644 index 0000000000..60f13fe355 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/forbidden-ext/b2/async-gen-func-expr-forbidden-ext-indirect-access-own-prop-caller-value.js @@ -0,0 +1,65 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/forbidden-ext-indirect-access-own-prop-caller-value.case +// - src/function-forms/forbidden-extensions/bullet-two/async-gen-func-expr.template +/*--- +description: Forbidden extension, o.caller (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [arrow-function, async-functions, async-iteration] +flags: [generated, noStrict, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + + If an implementation extends any function object with an own property named "caller" the value of + that property, as observed using [[Get]] or [[GetOwnProperty]], must not be a strict function + object. If it is an accessor property, the function that is the value of the property's [[Get]] + attribute must never return a strict function when called. + +---*/ +var CALLER_OWN_PROPERTY_DOES_NOT_EXIST = Symbol(); +function inner() { + // This property may exist, but is forbidden from having a value that is a strict function object + return inner.hasOwnProperty("caller") + ? inner.caller + : CALLER_OWN_PROPERTY_DOES_NOT_EXIST; +} + + +var callCount = 0; +var f; +f = async function*() { + "use strict"; + // This and the following conditional value is set in the test's .case file. + // For every test that has a "true" value here, there is a + // corresponding test that has a "false" value here. + // They are generated from two different case files, which use + // the same templates. + let descriptor = Object.getOwnPropertyDescriptor(inner, "caller"); + if (descriptor && descriptor.configurable && true) { + Object.defineProperty(inner, "caller", {value: 1}); + } + var result = inner(); + if (descriptor && descriptor.configurable && true) { + assert.sameValue(result, 1, 'If this test defined an own "caller" property on the inner function, then it should be accessible and should return the value it was set to.'); + } + // "CALLER_OWN_PROPERTY_DOES_NOT_EXIST" is from + // forbidden-ext-indirect-access-prop-caller.case + // + // If the function object "inner" has an own property + // named "caller", then its value will be returned. + // + // If the function object "inner" DOES NOT have an + // own property named "caller", then the symbol + // CALLER_OWN_PROPERTY_DOES_NOT_EXIST will be returned. + if (result !== CALLER_OWN_PROPERTY_DOES_NOT_EXIST) { + assert.notSameValue(result, f); + } + callCount++; +}; + +f().next() + .then(() => { + assert.sameValue(callCount, 1, 'function body evaluated'); + }, $DONE).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/async-generator/forbidden-ext/b2/async-gen-func-expr-forbidden-ext-indirect-access-prop-caller.js b/js/src/tests/test262/language/expressions/async-generator/forbidden-ext/b2/async-gen-func-expr-forbidden-ext-indirect-access-prop-caller.js new file mode 100644 index 0000000000..e15c292832 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/forbidden-ext/b2/async-gen-func-expr-forbidden-ext-indirect-access-prop-caller.js @@ -0,0 +1,65 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/forbidden-ext-indirect-access-prop-caller.case +// - src/function-forms/forbidden-extensions/bullet-two/async-gen-func-expr.template +/*--- +description: Forbidden extension, o.caller (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [arrow-function, async-functions, async-iteration] +flags: [generated, noStrict, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + + If an implementation extends any function object with an own property named "caller" the value of + that property, as observed using [[Get]] or [[GetOwnProperty]], must not be a strict function + object. If it is an accessor property, the function that is the value of the property's [[Get]] + attribute must never return a strict function when called. + +---*/ +var CALLER_OWN_PROPERTY_DOES_NOT_EXIST = Symbol(); +function inner() { + // This property may exist, but is forbidden from having a value that is a strict function object + return inner.hasOwnProperty("caller") + ? inner.caller + : CALLER_OWN_PROPERTY_DOES_NOT_EXIST; +} + + +var callCount = 0; +var f; +f = async function*() { + "use strict"; + // This and the following conditional value is set in the test's .case file. + // For every test that has a "true" value here, there is a + // corresponding test that has a "false" value here. + // They are generated from two different case files, which use + // the same templates. + let descriptor = Object.getOwnPropertyDescriptor(inner, "caller"); + if (descriptor && descriptor.configurable && false) { + Object.defineProperty(inner, "caller", {}); + } + var result = inner(); + if (descriptor && descriptor.configurable && false) { + assert.sameValue(result, 1, 'If this test defined an own "caller" property on the inner function, then it should be accessible and should return the value it was set to.'); + } + // "CALLER_OWN_PROPERTY_DOES_NOT_EXIST" is from + // forbidden-ext-indirect-access-prop-caller.case + // + // If the function object "inner" has an own property + // named "caller", then its value will be returned. + // + // If the function object "inner" DOES NOT have an + // own property named "caller", then the symbol + // CALLER_OWN_PROPERTY_DOES_NOT_EXIST will be returned. + if (result !== CALLER_OWN_PROPERTY_DOES_NOT_EXIST) { + assert.notSameValue(result, f); + } + callCount++; +}; + +f().next() + .then(() => { + assert.sameValue(callCount, 1, 'function body evaluated'); + }, $DONE).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/async-generator/forbidden-ext/b2/async-gen-named-func-expr-forbidden-ext-indirect-access-own-prop-caller-get.js b/js/src/tests/test262/language/expressions/async-generator/forbidden-ext/b2/async-gen-named-func-expr-forbidden-ext-indirect-access-own-prop-caller-get.js new file mode 100644 index 0000000000..b033e2d359 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/forbidden-ext/b2/async-gen-named-func-expr-forbidden-ext-indirect-access-own-prop-caller-get.js @@ -0,0 +1,65 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/forbidden-ext-indirect-access-own-prop-caller-get.case +// - src/function-forms/forbidden-extensions/bullet-two/async-gen-named-func-expr.template +/*--- +description: Forbidden extension, o.caller (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [arrow-function, async-functions, async-iteration] +flags: [generated, noStrict, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + + If an implementation extends any function object with an own property named "caller" the value of + that property, as observed using [[Get]] or [[GetOwnProperty]], must not be a strict function + object. If it is an accessor property, the function that is the value of the property's [[Get]] + attribute must never return a strict function when called. + +---*/ +var CALLER_OWN_PROPERTY_DOES_NOT_EXIST = Symbol(); +function inner() { + // This property may exist, but is forbidden from having a value that is a strict function object + return inner.hasOwnProperty("caller") + ? inner.caller + : CALLER_OWN_PROPERTY_DOES_NOT_EXIST; +} + + +var callCount = 0; +var f; +f = async function* g() { + "use strict"; + // This and the following conditional value is set in the test's .case file. + // For every test that has a "true" value here, there is a + // corresponding test that has a "false" value here. + // They are generated from two different case files, which use + // the same templates. + let descriptor = Object.getOwnPropertyDescriptor(inner, "caller"); + if (descriptor && descriptor.configurable && true) { + Object.defineProperty(inner, "caller", {get(){return 1}}); + } + var result = inner(); + if (descriptor && descriptor.configurable && true) { + assert.sameValue(result, 1, 'If this test defined an own "caller" property on the inner function, then it should be accessible and should return the value it was set to.'); + } + // "CALLER_OWN_PROPERTY_DOES_NOT_EXIST" is from + // forbidden-ext-indirect-access-prop-caller.case + // + // If the function object "inner" has an own property + // named "caller", then its value will be returned. + // + // If the function object "inner" DOES NOT have an + // own property named "caller", then the symbol + // CALLER_OWN_PROPERTY_DOES_NOT_EXIST will be returned. + if (result !== CALLER_OWN_PROPERTY_DOES_NOT_EXIST) { + assert.notSameValue(result, f); + } + callCount++; +}; + +f().next() + .then(() => { + assert.sameValue(callCount, 1, 'function body evaluated'); + }, $DONE).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/async-generator/forbidden-ext/b2/async-gen-named-func-expr-forbidden-ext-indirect-access-own-prop-caller-value.js b/js/src/tests/test262/language/expressions/async-generator/forbidden-ext/b2/async-gen-named-func-expr-forbidden-ext-indirect-access-own-prop-caller-value.js new file mode 100644 index 0000000000..fd99288e11 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/forbidden-ext/b2/async-gen-named-func-expr-forbidden-ext-indirect-access-own-prop-caller-value.js @@ -0,0 +1,65 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/forbidden-ext-indirect-access-own-prop-caller-value.case +// - src/function-forms/forbidden-extensions/bullet-two/async-gen-named-func-expr.template +/*--- +description: Forbidden extension, o.caller (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [arrow-function, async-functions, async-iteration] +flags: [generated, noStrict, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + + If an implementation extends any function object with an own property named "caller" the value of + that property, as observed using [[Get]] or [[GetOwnProperty]], must not be a strict function + object. If it is an accessor property, the function that is the value of the property's [[Get]] + attribute must never return a strict function when called. + +---*/ +var CALLER_OWN_PROPERTY_DOES_NOT_EXIST = Symbol(); +function inner() { + // This property may exist, but is forbidden from having a value that is a strict function object + return inner.hasOwnProperty("caller") + ? inner.caller + : CALLER_OWN_PROPERTY_DOES_NOT_EXIST; +} + + +var callCount = 0; +var f; +f = async function* g() { + "use strict"; + // This and the following conditional value is set in the test's .case file. + // For every test that has a "true" value here, there is a + // corresponding test that has a "false" value here. + // They are generated from two different case files, which use + // the same templates. + let descriptor = Object.getOwnPropertyDescriptor(inner, "caller"); + if (descriptor && descriptor.configurable && true) { + Object.defineProperty(inner, "caller", {value: 1}); + } + var result = inner(); + if (descriptor && descriptor.configurable && true) { + assert.sameValue(result, 1, 'If this test defined an own "caller" property on the inner function, then it should be accessible and should return the value it was set to.'); + } + // "CALLER_OWN_PROPERTY_DOES_NOT_EXIST" is from + // forbidden-ext-indirect-access-prop-caller.case + // + // If the function object "inner" has an own property + // named "caller", then its value will be returned. + // + // If the function object "inner" DOES NOT have an + // own property named "caller", then the symbol + // CALLER_OWN_PROPERTY_DOES_NOT_EXIST will be returned. + if (result !== CALLER_OWN_PROPERTY_DOES_NOT_EXIST) { + assert.notSameValue(result, f); + } + callCount++; +}; + +f().next() + .then(() => { + assert.sameValue(callCount, 1, 'function body evaluated'); + }, $DONE).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/async-generator/forbidden-ext/b2/async-gen-named-func-expr-forbidden-ext-indirect-access-prop-caller.js b/js/src/tests/test262/language/expressions/async-generator/forbidden-ext/b2/async-gen-named-func-expr-forbidden-ext-indirect-access-prop-caller.js new file mode 100644 index 0000000000..24a7c4f53a --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/forbidden-ext/b2/async-gen-named-func-expr-forbidden-ext-indirect-access-prop-caller.js @@ -0,0 +1,65 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/forbidden-ext-indirect-access-prop-caller.case +// - src/function-forms/forbidden-extensions/bullet-two/async-gen-named-func-expr.template +/*--- +description: Forbidden extension, o.caller (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [arrow-function, async-functions, async-iteration] +flags: [generated, noStrict, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + + If an implementation extends any function object with an own property named "caller" the value of + that property, as observed using [[Get]] or [[GetOwnProperty]], must not be a strict function + object. If it is an accessor property, the function that is the value of the property's [[Get]] + attribute must never return a strict function when called. + +---*/ +var CALLER_OWN_PROPERTY_DOES_NOT_EXIST = Symbol(); +function inner() { + // This property may exist, but is forbidden from having a value that is a strict function object + return inner.hasOwnProperty("caller") + ? inner.caller + : CALLER_OWN_PROPERTY_DOES_NOT_EXIST; +} + + +var callCount = 0; +var f; +f = async function* g() { + "use strict"; + // This and the following conditional value is set in the test's .case file. + // For every test that has a "true" value here, there is a + // corresponding test that has a "false" value here. + // They are generated from two different case files, which use + // the same templates. + let descriptor = Object.getOwnPropertyDescriptor(inner, "caller"); + if (descriptor && descriptor.configurable && false) { + Object.defineProperty(inner, "caller", {}); + } + var result = inner(); + if (descriptor && descriptor.configurable && false) { + assert.sameValue(result, 1, 'If this test defined an own "caller" property on the inner function, then it should be accessible and should return the value it was set to.'); + } + // "CALLER_OWN_PROPERTY_DOES_NOT_EXIST" is from + // forbidden-ext-indirect-access-prop-caller.case + // + // If the function object "inner" has an own property + // named "caller", then its value will be returned. + // + // If the function object "inner" DOES NOT have an + // own property named "caller", then the symbol + // CALLER_OWN_PROPERTY_DOES_NOT_EXIST will be returned. + if (result !== CALLER_OWN_PROPERTY_DOES_NOT_EXIST) { + assert.notSameValue(result, f); + } + callCount++; +}; + +f().next() + .then(() => { + assert.sameValue(callCount, 1, 'function body evaluated'); + }, $DONE).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/async-generator/forbidden-ext/b2/browser.js b/js/src/tests/test262/language/expressions/async-generator/forbidden-ext/b2/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/forbidden-ext/b2/browser.js diff --git a/js/src/tests/test262/language/expressions/async-generator/forbidden-ext/b2/shell.js b/js/src/tests/test262/language/expressions/async-generator/forbidden-ext/b2/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/forbidden-ext/b2/shell.js diff --git a/js/src/tests/test262/language/expressions/async-generator/forbidden-ext/browser.js b/js/src/tests/test262/language/expressions/async-generator/forbidden-ext/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/forbidden-ext/browser.js diff --git a/js/src/tests/test262/language/expressions/async-generator/forbidden-ext/shell.js b/js/src/tests/test262/language/expressions/async-generator/forbidden-ext/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/forbidden-ext/shell.js diff --git a/js/src/tests/test262/language/expressions/async-generator/generator-created-after-decl-inst.js b/js/src/tests/test262/language/expressions/async-generator/generator-created-after-decl-inst.js new file mode 100644 index 0000000000..9d74e66534 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/generator-created-after-decl-inst.js @@ -0,0 +1,26 @@ +// Copyright (C) 2018 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-asyncgenerator-definitions-evaluatebody +description: > + The generator object is created after FunctionDeclarationInstantiation. +info: | + 14.5.10 Runtime Semantics: EvaluateBody + + 1. Perform ? FunctionDeclarationInstantiation(functionObject, argumentsList). + 2. Let generator be ? OrdinaryCreateFromConstructor(functionObject, "%AsyncGeneratorPrototype%", + « [[AsyncGeneratorState]], [[AsyncGeneratorContext]], [[AsyncGeneratorQueue]] »). + 3. Perform ! AsyncGeneratorStart(generator, FunctionBody). + ... + +features: [async-iteration] +---*/ + +var g = async function*(a = (g.prototype = null)) {} +var oldPrototype = g.prototype; +var it = g(); + +assert.notSameValue(Object.getPrototypeOf(it), oldPrototype); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/name.js b/js/src/tests/test262/language/expressions/async-generator/name.js new file mode 100644 index 0000000000..4dfd2d458d --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/name.js @@ -0,0 +1,38 @@ +// Copyright (C) 2019 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-asyncgenerator-definitions-evaluation +description: Assignment of function `name` attribute +info: | + AsyncGeneratorExpression : async function * ( FormalParameters ) { AsyncGeneratorBody } + + 1. Let scope be the LexicalEnvironment of the running execution context. + 2. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, ""). + ... + 6. Return closure. + + AsyncGeneratorExpression : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + + 1. Let scope be the running execution context's LexicalEnvironment. + 2. Let funcEnv be ! NewDeclarativeEnvironment(scope). + 3. Let envRec be funcEnv's EnvironmentRecord. + 4. Let name be StringValue of BindingIdentifier. + 5. Perform ! envRec.CreateImmutableBinding(name). + 6. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, name). + ... + 11. Return closure. +includes: [propertyHelper.js] +---*/ + +verifyProperty(async function*() {}, "name", { + value: "", writable: false, enumerable: false, configurable: true +}); + +verifyProperty(async function* func() {}, "name", { + value: "func", writable: false, enumerable: false, configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/named-array-destructuring-param-strict-body.js b/js/src/tests/test262/language/expressions/async-generator/named-array-destructuring-param-strict-body.js new file mode 100644 index 0000000000..55d242fd7b --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-array-destructuring-param-strict-body.js @@ -0,0 +1,113 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/array-destructuring-param-strict-body.case +// - src/function-forms/syntax/async-gen-named-func-expr.template +/*--- +description: ArrayBindingPattern and Use Strict Directive are not allowed to coexist for the same function. (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [rest-parameters, async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + + 13.3.3.4 Static Semantics: IsSimpleParameterList + + BindingElement : BindingPattern + + 1. Return false. + + 14.1.2 Static Semantics: Early Errors + + FunctionDeclaration : function BindingIdentifier ( FormalParameters ) { FunctionBody } + FunctionDeclaration : function ( FormalParameters ) { FunctionBody } + FunctionExpression : function BindingIdentifier ( FormalParameters ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.2.1 Static Semantics: Early Errors + + ArrowFunction : ArrowParameters => ConciseBody + + - It is a Syntax Error if ContainsUseStrict of ConciseBody is true and + IsSimpleParameterList of ArrowParameters is false. + + 14.3.1 Static Semantics: Early Errors + + MethodDefinition : PropertyName ( UniqueFormalParameters ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + MethodDefinition : set PropertyName ( PropertySetParameterList ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of PropertySetParameterList is false. + + 14.4.1 Static Semantics: Early Errors + + GeneratorMethod : * PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of GeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + GeneratorDeclaration : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + GeneratorExpression : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of GeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + 14.5.1 Static Semantics: Early Errors + + AsyncGeneratorMethod : async * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncGeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + AsyncGeneratorDeclaration : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + AsyncGeneratorDeclaration : async function * ( FormalParameters ) { AsyncGeneratorBody } + AsyncGeneratorExpression : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncGeneratorBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.7.1 Static Semantics: Early Errors + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncFunctionBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + AsyncFunctionDeclaration : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionDeclaration : async function ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionExpression : async function ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionExpression : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncFunctionBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.8.1 Static Semantics: Early Errors + + AsyncArrowFunction : CoverCallExpressionAndAsyncArrowHead => AsyncConciseBody + + - It is a Syntax Error if ContainsUseStrict of AsyncConciseBody is true and + IsSimpleParameterList of CoverCallExpressionAndAsyncArrowHead is false. + +---*/ +$DONOTEVALUATE(); + + +0, async function* g([element]) { + "use strict"; +}; diff --git a/js/src/tests/test262/language/expressions/async-generator/named-await-as-binding-identifier-escaped.js b/js/src/tests/test262/language/expressions/async-generator/named-await-as-binding-identifier-escaped.js new file mode 100644 index 0000000000..4653cf575e --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-await-as-binding-identifier-escaped.js @@ -0,0 +1,32 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-generators/await-as-binding-identifier-escaped.case +// - src/async-generators/syntax/async-expression-named.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + BindingIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +$DONOTEVALUATE(); + + +var gen = async function *g() { + var \u0061wait; +}; diff --git a/js/src/tests/test262/language/expressions/async-generator/named-await-as-binding-identifier.js b/js/src/tests/test262/language/expressions/async-generator/named-await-as-binding-identifier.js new file mode 100644 index 0000000000..cac883210c --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-await-as-binding-identifier.js @@ -0,0 +1,32 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-generators/await-as-binding-identifier.case +// - src/async-generators/syntax/async-expression-named.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + BindingIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +$DONOTEVALUATE(); + + +var gen = async function *g() { + var await; +}; diff --git a/js/src/tests/test262/language/expressions/async-generator/named-await-as-identifier-reference-escaped.js b/js/src/tests/test262/language/expressions/async-generator/named-await-as-identifier-reference-escaped.js new file mode 100644 index 0000000000..b4d9f6e00e --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-await-as-identifier-reference-escaped.js @@ -0,0 +1,32 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-generators/await-as-identifier-reference-escaped.case +// - src/async-generators/syntax/async-expression-named.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + IdentifierReference : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +$DONOTEVALUATE(); + + +var gen = async function *g() { + void \u0061wait; +}; diff --git a/js/src/tests/test262/language/expressions/async-generator/named-await-as-identifier-reference.js b/js/src/tests/test262/language/expressions/async-generator/named-await-as-identifier-reference.js new file mode 100644 index 0000000000..ebc00efaae --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-await-as-identifier-reference.js @@ -0,0 +1,32 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-generators/await-as-identifier-reference.case +// - src/async-generators/syntax/async-expression-named.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + IdentifierReference : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +$DONOTEVALUATE(); + + +var gen = async function *g() { + void await; +}; diff --git a/js/src/tests/test262/language/expressions/async-generator/named-await-as-label-identifier-escaped.js b/js/src/tests/test262/language/expressions/async-generator/named-await-as-label-identifier-escaped.js new file mode 100644 index 0000000000..e15ea1760c --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-await-as-label-identifier-escaped.js @@ -0,0 +1,32 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-generators/await-as-label-identifier-escaped.case +// - src/async-generators/syntax/async-expression-named.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a label identifier. (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + LabelIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +$DONOTEVALUATE(); + + +var gen = async function *g() { + \u0061wait: ; +}; diff --git a/js/src/tests/test262/language/expressions/async-generator/named-await-as-label-identifier.js b/js/src/tests/test262/language/expressions/async-generator/named-await-as-label-identifier.js new file mode 100644 index 0000000000..d189f17d06 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-await-as-label-identifier.js @@ -0,0 +1,32 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-generators/await-as-label-identifier.case +// - src/async-generators/syntax/async-expression-named.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a label identifier. (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + LabelIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +$DONOTEVALUATE(); + + +var gen = async function *g() { + await: ; +}; diff --git a/js/src/tests/test262/language/expressions/async-generator/named-dflt-params-abrupt.js b/js/src/tests/test262/language/expressions/async-generator/named-dflt-params-abrupt.js new file mode 100644 index 0000000000..d3c1e3b4a2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-dflt-params-abrupt.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-abrupt.case +// - src/function-forms/error/async-gen-named-func-expr.template +/*--- +description: Abrupt completion returned by evaluation of initializer (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [default-parameters, async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. + +---*/ + + +var callCount = 0; +var f; +f = async function* g(_ = (function() { throw new Test262Error(); }())) { + + callCount = callCount + 1; +}; + +assert.throws(Test262Error, function() { + f(); +}); +assert.sameValue(callCount, 0, 'generator function body not evaluated'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/named-dflt-params-arg-val-not-undefined.js b/js/src/tests/test262/language/expressions/async-generator/named-dflt-params-arg-val-not-undefined.js new file mode 100644 index 0000000000..9599a09907 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-dflt-params-arg-val-not-undefined.js @@ -0,0 +1,66 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-arg-val-not-undefined.case +// - src/function-forms/default/async-gen-named-func-expr.template +/*--- +description: Use of initializer when argument value is not `undefined` (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [default-parameters, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + [...] + 23. Let iteratorRecord be Record {[[Iterator]]: + CreateListIterator(argumentsList), [[Done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + a. Perform ? IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + +---*/ +var obj = {}; +var falseCount = 0; +var stringCount = 0; +var nanCount = 0; +var zeroCount = 0; +var nullCount = 0; +var objCount = 0; + + +var callCount = 0; +// Stores a reference `ref` for case evaluation +var ref; +ref = async function* g(aFalse = falseCount +=1, aString = stringCount += 1, aNaN = nanCount += 1, a0 = zeroCount += 1, aNull = nullCount += 1, aObj = objCount +=1) { + assert.sameValue(aFalse, false); + assert.sameValue(aString, ''); + assert.sameValue(aNaN, NaN); + assert.sameValue(a0, 0); + assert.sameValue(aNull, null); + assert.sameValue(aObj, obj); + callCount = callCount + 1; +}; + +ref(false, '', NaN, 0, null, obj).next().then(() => { + assert.sameValue(callCount, 1, 'generator function invoked exactly once'); +}).then($DONE, $DONE); + +assert.sameValue(falseCount, 0, 'initializer not evaluated: false'); +assert.sameValue(stringCount, 0, 'initializer not evaluated: string'); +assert.sameValue(nanCount, 0, 'initializer not evaluated: NaN'); +assert.sameValue(zeroCount, 0, 'initializer not evaluated: 0'); +assert.sameValue(nullCount, 0, 'initializer not evaluated: null'); +assert.sameValue(objCount, 0, 'initializer not evaluated: object'); diff --git a/js/src/tests/test262/language/expressions/async-generator/named-dflt-params-arg-val-undefined.js b/js/src/tests/test262/language/expressions/async-generator/named-dflt-params-arg-val-undefined.js new file mode 100644 index 0000000000..a1822f2d5a --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-dflt-params-arg-val-undefined.js @@ -0,0 +1,49 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-arg-val-undefined.case +// - src/function-forms/default/async-gen-named-func-expr.template +/*--- +description: Use of initializer when argument value is `undefined` (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [default-parameters, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + [...] + 23. Let iteratorRecord be Record {[[Iterator]]: + CreateListIterator(argumentsList), [[Done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + a. Perform ? IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + +---*/ + + +var callCount = 0; +// Stores a reference `ref` for case evaluation +var ref; +ref = async function* g(fromLiteral = 23, fromExpr = 45, fromHole = 99) { + assert.sameValue(fromLiteral, 23); + assert.sameValue(fromExpr, 45); + assert.sameValue(fromHole, 99); + callCount = callCount + 1; +}; + +ref(undefined, void 0).next().then(() => { + assert.sameValue(callCount, 1, 'generator function invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/async-generator/named-dflt-params-duplicates.js b/js/src/tests/test262/language/expressions/async-generator/named-dflt-params-duplicates.js new file mode 100644 index 0000000000..9fd77d7680 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-dflt-params-duplicates.js @@ -0,0 +1,42 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-duplicates.case +// - src/function-forms/syntax/async-gen-named-func-expr.template +/*--- +description: It is a Syntax Error if BoundNames of FormalParameters contains any duplicate elements. (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [default-parameters, async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + + 14.1.2 Static Semantics: Early Errors + + StrictFormalParameters : FormalParameters + + - It is a Syntax Error if BoundNames of FormalParameters contains any + duplicate elements. + + FormalParameters : FormalParameterList + + - It is a Syntax Error if IsSimpleParameterList of FormalParameterList is + false and BoundNames of FormalParameterList contains any duplicate + elements. + +---*/ +$DONOTEVALUATE(); + + +0, async function* g(x = 0, x) { + +}; diff --git a/js/src/tests/test262/language/expressions/async-generator/named-dflt-params-ref-later.js b/js/src/tests/test262/language/expressions/async-generator/named-dflt-params-ref-later.js new file mode 100644 index 0000000000..a57df156aa --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-dflt-params-ref-later.js @@ -0,0 +1,45 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-ref-later.case +// - src/function-forms/error/async-gen-named-func-expr.template +/*--- +description: Referencing a parameter that occurs later in the ParameterList (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [default-parameters, async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. + +---*/ +var x = 0; + + +var callCount = 0; +var f; +f = async function* g(x = y, y) { + + callCount = callCount + 1; +}; + +assert.throws(ReferenceError, function() { + f(); +}); +assert.sameValue(callCount, 0, 'generator function body not evaluated'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/named-dflt-params-ref-prior.js b/js/src/tests/test262/language/expressions/async-generator/named-dflt-params-ref-prior.js new file mode 100644 index 0000000000..6b23c62f38 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-dflt-params-ref-prior.js @@ -0,0 +1,46 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-ref-prior.case +// - src/function-forms/default/async-gen-named-func-expr.template +/*--- +description: Referencing a parameter that occurs earlier in the ParameterList (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [default-parameters, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. + +---*/ +var x = 0; + + +var callCount = 0; +// Stores a reference `ref` for case evaluation +var ref; +ref = async function* g(x, y = x, z = y) { + assert.sameValue(x, 3, 'first argument value'); + assert.sameValue(y, 3, 'second argument value'); + assert.sameValue(z, 3, 'third argument value'); + callCount = callCount + 1; +}; + +ref(3).next().then(() => { + assert.sameValue(callCount, 1, 'generator function invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/async-generator/named-dflt-params-ref-self.js b/js/src/tests/test262/language/expressions/async-generator/named-dflt-params-ref-self.js new file mode 100644 index 0000000000..06abd430c8 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-dflt-params-ref-self.js @@ -0,0 +1,45 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-ref-self.case +// - src/function-forms/error/async-gen-named-func-expr.template +/*--- +description: Referencing a parameter from within its own initializer (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [default-parameters, async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. + +---*/ +var x = 0; + + +var callCount = 0; +var f; +f = async function* g(x = x) { + + callCount = callCount + 1; +}; + +assert.throws(ReferenceError, function() { + f(); +}); +assert.sameValue(callCount, 0, 'generator function body not evaluated'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/named-dflt-params-rest.js b/js/src/tests/test262/language/expressions/async-generator/named-dflt-params-rest.js new file mode 100644 index 0000000000..67e8ee7e84 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-dflt-params-rest.js @@ -0,0 +1,46 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-rest.case +// - src/function-forms/syntax/async-gen-named-func-expr.template +/*--- +description: RestParameter does not support an initializer (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [default-parameters, async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + + 14.1 Function Definitions + + Syntax + + FunctionRestParameter[Yield] : + + BindingRestElement[?Yield] + + 13.3.3 Destructuring Binding Patterns + + Syntax + + BindingRestElement[Yield] : + + ...BindingIdentifier[?Yield] + ...BindingPattern[?Yield] + +---*/ +$DONOTEVALUATE(); + + +0, async function* g(...x = []) { + +}; diff --git a/js/src/tests/test262/language/expressions/async-generator/named-dflt-params-trailing-comma.js b/js/src/tests/test262/language/expressions/async-generator/named-dflt-params-trailing-comma.js new file mode 100644 index 0000000000..7697a9613b --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-dflt-params-trailing-comma.js @@ -0,0 +1,41 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-trailing-comma.case +// - src/function-forms/default/async-gen-named-func-expr.template +/*--- +description: A trailing comma should not increase the respective length, using default parameters (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + + Trailing comma in the parameters list + + 14.1 Function Definitions + + FormalParameters[Yield, Await] : FormalParameterList[?Yield, ?Await] , +---*/ + + +var callCount = 0; +// Stores a reference `ref` for case evaluation +var ref; +ref = async function* g(a, b = 39,) { + assert.sameValue(a, 42); + assert.sameValue(b, 39); + callCount = callCount + 1; +}; + +ref(42, undefined, 1).next().then(() => { + assert.sameValue(callCount, 1, 'generator function invoked exactly once'); +}).then($DONE, $DONE); + +assert.sameValue(ref.length, 1, 'length is properly set'); diff --git a/js/src/tests/test262/language/expressions/async-generator/named-eval-var-scope-syntax-err.js b/js/src/tests/test262/language/expressions/async-generator/named-eval-var-scope-syntax-err.js new file mode 100644 index 0000000000..1f80e5ff9d --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-eval-var-scope-syntax-err.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/eval-var-scope-syntax-err.case +// - src/function-forms/error-no-strict/async-gen-named-func-expr.template +/*--- +description: sloppy direct eval in params introduces var (async generator named function expression in sloppy code) +esid: sec-asyncgenerator-definitions-evaluation +features: [default-parameters, async-iteration] +flags: [generated, noStrict] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + + + Runtime Semantics: IteratorBindingInitialization + FormalParameter : BindingElement + + 1. Return the result of performing IteratorBindingInitialization for BindingElement with arguments iteratorRecord and environment. + +---*/ + + +var callCount = 0; +var f; +f = async function* g(a = eval("var a = 42")) { + + callCount = callCount + 1; +}; + +assert.throws(SyntaxError, function() { + f(); +}); +assert.sameValue(callCount, 0, 'generator function body not evaluated'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/async-generator/named-no-strict-reassign-fn-name-in-body-in-arrow.js b/js/src/tests/test262/language/expressions/async-generator/named-no-strict-reassign-fn-name-in-body-in-arrow.js new file mode 100644 index 0000000000..27c70d438a --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-no-strict-reassign-fn-name-in-body-in-arrow.js @@ -0,0 +1,31 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/reassign-fn-name-in-body-in-arrow.case +// - src/function-forms/expr-named/async-gen-func-expr-named-no-strict.template +/*--- +description: Reassignment of function name is silently ignored in non-strict mode code. (async generator named function expression in non-strict mode code) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async, noStrict] +includes: [asyncHelpers.js] +info: | + AsyncGeneratorExpression : + async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + +---*/ + +// increment callCount in case "body" +let callCount = 0; +let ref = async function * BindingIdentifier() { + callCount++; + (() => { + BindingIdentifier = 1; + })(); + return BindingIdentifier; +}; + +asyncTest(async () => { + assert.sameValue((await (await ref()).next()).value, ref); + assert.sameValue(callCount, 1, 'function invoked exactly once'); +}); + diff --git a/js/src/tests/test262/language/expressions/async-generator/named-no-strict-reassign-fn-name-in-body-in-eval.js b/js/src/tests/test262/language/expressions/async-generator/named-no-strict-reassign-fn-name-in-body-in-eval.js new file mode 100644 index 0000000000..f707a29d64 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-no-strict-reassign-fn-name-in-body-in-eval.js @@ -0,0 +1,29 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/reassign-fn-name-in-body-in-eval.case +// - src/function-forms/expr-named/async-gen-func-expr-named-no-strict.template +/*--- +description: Reassignment of function name is silently ignored in non-strict mode code. (async generator named function expression in non-strict mode code) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async, noStrict] +includes: [asyncHelpers.js] +info: | + AsyncGeneratorExpression : + async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + +---*/ + +// increment callCount in case "body" +let callCount = 0; +let ref = async function * BindingIdentifier() { + callCount++; + eval("BindingIdentifier = 1"); + return BindingIdentifier; +}; + +asyncTest(async () => { + assert.sameValue((await (await ref()).next()).value, ref); + assert.sameValue(callCount, 1, 'function invoked exactly once'); +}); + diff --git a/js/src/tests/test262/language/expressions/async-generator/named-no-strict-reassign-fn-name-in-body.js b/js/src/tests/test262/language/expressions/async-generator/named-no-strict-reassign-fn-name-in-body.js new file mode 100644 index 0000000000..2d5733f65a --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-no-strict-reassign-fn-name-in-body.js @@ -0,0 +1,29 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/reassign-fn-name-in-body.case +// - src/function-forms/expr-named/async-gen-func-expr-named-no-strict.template +/*--- +description: Reassignment of function name is silently ignored in non-strict mode code. (async generator named function expression in non-strict mode code) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async, noStrict] +includes: [asyncHelpers.js] +info: | + AsyncGeneratorExpression : + async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + +---*/ + +// increment callCount in case "body" +let callCount = 0; +let ref = async function * BindingIdentifier() { + callCount++; + BindingIdentifier = 1; + return BindingIdentifier; +}; + +asyncTest(async () => { + assert.sameValue((await (await ref()).next()).value, ref); + assert.sameValue(callCount, 1, 'function invoked exactly once'); +}); + diff --git a/js/src/tests/test262/language/expressions/async-generator/named-object-destructuring-param-strict-body.js b/js/src/tests/test262/language/expressions/async-generator/named-object-destructuring-param-strict-body.js new file mode 100644 index 0000000000..1b6d5ef9dd --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-object-destructuring-param-strict-body.js @@ -0,0 +1,113 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/object-destructuring-param-strict-body.case +// - src/function-forms/syntax/async-gen-named-func-expr.template +/*--- +description: ObjectBindingPattern and Use Strict Directive are not allowed to coexist for the same function. (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [rest-parameters, async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + + 13.3.3.4 Static Semantics: IsSimpleParameterList + + BindingElement : BindingPattern + + 1. Return false. + + 14.1.2 Static Semantics: Early Errors + + FunctionDeclaration : function BindingIdentifier ( FormalParameters ) { FunctionBody } + FunctionDeclaration : function ( FormalParameters ) { FunctionBody } + FunctionExpression : function BindingIdentifier ( FormalParameters ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.2.1 Static Semantics: Early Errors + + ArrowFunction : ArrowParameters => ConciseBody + + - It is a Syntax Error if ContainsUseStrict of ConciseBody is true and + IsSimpleParameterList of ArrowParameters is false. + + 14.3.1 Static Semantics: Early Errors + + MethodDefinition : PropertyName ( UniqueFormalParameters ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + MethodDefinition : set PropertyName ( PropertySetParameterList ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of PropertySetParameterList is false. + + 14.4.1 Static Semantics: Early Errors + + GeneratorMethod : * PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of GeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + GeneratorDeclaration : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + GeneratorExpression : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of GeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + 14.5.1 Static Semantics: Early Errors + + AsyncGeneratorMethod : async * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncGeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + AsyncGeneratorDeclaration : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + AsyncGeneratorDeclaration : async function * ( FormalParameters ) { AsyncGeneratorBody } + AsyncGeneratorExpression : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncGeneratorBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.7.1 Static Semantics: Early Errors + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncFunctionBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + AsyncFunctionDeclaration : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionDeclaration : async function ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionExpression : async function ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionExpression : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncFunctionBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.8.1 Static Semantics: Early Errors + + AsyncArrowFunction : CoverCallExpressionAndAsyncArrowHead => AsyncConciseBody + + - It is a Syntax Error if ContainsUseStrict of AsyncConciseBody is true and + IsSimpleParameterList of CoverCallExpressionAndAsyncArrowHead is false. + +---*/ +$DONOTEVALUATE(); + + +0, async function* g({property}) { + "use strict"; +}; diff --git a/js/src/tests/test262/language/expressions/async-generator/named-params-trailing-comma-multiple.js b/js/src/tests/test262/language/expressions/async-generator/named-params-trailing-comma-multiple.js new file mode 100644 index 0000000000..2206c44438 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-params-trailing-comma-multiple.js @@ -0,0 +1,41 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/params-trailing-comma-multiple.case +// - src/function-forms/default/async-gen-named-func-expr.template +/*--- +description: A trailing comma should not increase the respective length, using multiple parameters (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + + Trailing comma in the parameters list + + 14.1 Function Definitions + + FormalParameters[Yield, Await] : FormalParameterList[?Yield, ?Await] , +---*/ + + +var callCount = 0; +// Stores a reference `ref` for case evaluation +var ref; +ref = async function* g(a, b,) { + assert.sameValue(a, 42); + assert.sameValue(b, 39); + callCount = callCount + 1; +}; + +ref(42, 39, 1).next().then(() => { + assert.sameValue(callCount, 1, 'generator function invoked exactly once'); +}).then($DONE, $DONE); + +assert.sameValue(ref.length, 2, 'length is properly set'); diff --git a/js/src/tests/test262/language/expressions/async-generator/named-params-trailing-comma-single.js b/js/src/tests/test262/language/expressions/async-generator/named-params-trailing-comma-single.js new file mode 100644 index 0000000000..30f73b4433 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-params-trailing-comma-single.js @@ -0,0 +1,40 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/params-trailing-comma-single.case +// - src/function-forms/default/async-gen-named-func-expr.template +/*--- +description: A trailing comma should not increase the respective length, using a single parameter (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + + Trailing comma in the parameters list + + 14.1 Function Definitions + + FormalParameters[Yield, Await] : FormalParameterList[?Yield, ?Await] , +---*/ + + +var callCount = 0; +// Stores a reference `ref` for case evaluation +var ref; +ref = async function* g(a,) { + assert.sameValue(a, 42); + callCount = callCount + 1; +}; + +ref(42, 39).next().then(() => { + assert.sameValue(callCount, 1, 'generator function invoked exactly once'); +}).then($DONE, $DONE); + +assert.sameValue(ref.length, 1, 'length is properly set'); diff --git a/js/src/tests/test262/language/expressions/async-generator/named-rest-param-strict-body.js b/js/src/tests/test262/language/expressions/async-generator/named-rest-param-strict-body.js new file mode 100644 index 0000000000..11675d2870 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-rest-param-strict-body.js @@ -0,0 +1,113 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/rest-param-strict-body.case +// - src/function-forms/syntax/async-gen-named-func-expr.template +/*--- +description: RestParameter and Use Strict Directive are not allowed to coexist for the same function. (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [rest-parameters, async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + + 14.1.13 Static Semantics: IsSimpleParameterList + + FormalParameters : FormalParameterList , FunctionRestParameter + + 1. Return false. + + 14.1.2 Static Semantics: Early Errors + + FunctionDeclaration : function BindingIdentifier ( FormalParameters ) { FunctionBody } + FunctionDeclaration : function ( FormalParameters ) { FunctionBody } + FunctionExpression : function BindingIdentifier ( FormalParameters ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.2.1 Static Semantics: Early Errors + + ArrowFunction : ArrowParameters => ConciseBody + + - It is a Syntax Error if ContainsUseStrict of ConciseBody is true and + IsSimpleParameterList of ArrowParameters is false. + + 14.3.1 Static Semantics: Early Errors + + MethodDefinition : PropertyName ( UniqueFormalParameters ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + MethodDefinition : set PropertyName ( PropertySetParameterList ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of PropertySetParameterList is false. + + 14.4.1 Static Semantics: Early Errors + + GeneratorMethod : * PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of GeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + GeneratorDeclaration : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + GeneratorExpression : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of GeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + 14.5.1 Static Semantics: Early Errors + + AsyncGeneratorMethod : async * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncGeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + AsyncGeneratorDeclaration : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + AsyncGeneratorDeclaration : async function * ( FormalParameters ) { AsyncGeneratorBody } + AsyncGeneratorExpression : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncGeneratorBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.7.1 Static Semantics: Early Errors + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncFunctionBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + AsyncFunctionDeclaration : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionDeclaration : async function ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionExpression : async function ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionExpression : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncFunctionBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.8.1 Static Semantics: Early Errors + + AsyncArrowFunction : CoverCallExpressionAndAsyncArrowHead => AsyncConciseBody + + - It is a Syntax Error if ContainsUseStrict of AsyncConciseBody is true and + IsSimpleParameterList of CoverCallExpressionAndAsyncArrowHead is false. + +---*/ +$DONOTEVALUATE(); + + +0, async function* g(a,...rest) { + "use strict"; +}; diff --git a/js/src/tests/test262/language/expressions/async-generator/named-rest-params-trailing-comma-early-error.js b/js/src/tests/test262/language/expressions/async-generator/named-rest-params-trailing-comma-early-error.js new file mode 100644 index 0000000000..1c760b6354 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-rest-params-trailing-comma-early-error.js @@ -0,0 +1,39 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/rest-params-trailing-comma-early-error.case +// - src/function-forms/syntax/async-gen-named-func-expr.template +/*--- +description: It's a syntax error if a FunctionRestParameter is followed by a trailing comma (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + + Trailing comma in the parameters list + + 14.1 Function Definitions + + FormalParameters[Yield, Await] : + [empty] + FunctionRestParameter[?Yield, ?Await] + FormalParameterList[?Yield, ?Await] + FormalParameterList[?Yield, ?Await] , + FormalParameterList[?Yield, ?Await] , FunctionRestParameter[?Yield, ?Await] +---*/ +$DONOTEVALUATE(); + + +0, async function* g(...a,) { + +}; diff --git a/js/src/tests/test262/language/expressions/async-generator/named-strict-error-reassign-fn-name-in-body-in-arrow-strict.js b/js/src/tests/test262/language/expressions/async-generator/named-strict-error-reassign-fn-name-in-body-in-arrow-strict.js new file mode 100644 index 0000000000..edadb9d94a --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-strict-error-reassign-fn-name-in-body-in-arrow-strict.js @@ -0,0 +1,39 @@ +// |reftest| async +'use strict'; +// This file was procedurally generated from the following sources: +// - src/function-forms/reassign-fn-name-in-body-in-arrow.case +// - src/function-forms/expr-named/async-gen-func-expr-named-strict-error.template +/*--- +description: Reassignment of function name is silently ignored in non-strict mode code. (async generator named function expression in strict mode code) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async, onlyStrict] +includes: [asyncHelpers.js] +info: | + AsyncGeneratorExpression : + async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + +---*/ + +// increment callCount in case "body" +let callCount = 0; +let ref = async function * BindingIdentifier() { + callCount++; + (() => { + BindingIdentifier = 1; + })(); + return BindingIdentifier; +}; + +asyncTest(async () => { + let catchCount = 0; + try { + (await (await ref()).next()).value + } catch (error) { + catchCount++; + assert(error instanceof TypeError); + } + assert.sameValue(catchCount, 1); + assert.sameValue(callCount, 1); +}); + diff --git a/js/src/tests/test262/language/expressions/async-generator/named-strict-error-reassign-fn-name-in-body-in-eval-strict.js b/js/src/tests/test262/language/expressions/async-generator/named-strict-error-reassign-fn-name-in-body-in-eval-strict.js new file mode 100644 index 0000000000..f59feecf43 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-strict-error-reassign-fn-name-in-body-in-eval-strict.js @@ -0,0 +1,37 @@ +// |reftest| async +'use strict'; +// This file was procedurally generated from the following sources: +// - src/function-forms/reassign-fn-name-in-body-in-eval.case +// - src/function-forms/expr-named/async-gen-func-expr-named-strict-error.template +/*--- +description: Reassignment of function name is silently ignored in non-strict mode code. (async generator named function expression in strict mode code) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async, onlyStrict] +includes: [asyncHelpers.js] +info: | + AsyncGeneratorExpression : + async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + +---*/ + +// increment callCount in case "body" +let callCount = 0; +let ref = async function * BindingIdentifier() { + callCount++; + eval("BindingIdentifier = 1"); + return BindingIdentifier; +}; + +asyncTest(async () => { + let catchCount = 0; + try { + (await (await ref()).next()).value + } catch (error) { + catchCount++; + assert(error instanceof TypeError); + } + assert.sameValue(catchCount, 1); + assert.sameValue(callCount, 1); +}); + diff --git a/js/src/tests/test262/language/expressions/async-generator/named-strict-error-reassign-fn-name-in-body-strict.js b/js/src/tests/test262/language/expressions/async-generator/named-strict-error-reassign-fn-name-in-body-strict.js new file mode 100644 index 0000000000..0a2df195c8 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-strict-error-reassign-fn-name-in-body-strict.js @@ -0,0 +1,37 @@ +// |reftest| async +'use strict'; +// This file was procedurally generated from the following sources: +// - src/function-forms/reassign-fn-name-in-body.case +// - src/function-forms/expr-named/async-gen-func-expr-named-strict-error.template +/*--- +description: Reassignment of function name is silently ignored in non-strict mode code. (async generator named function expression in strict mode code) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async, onlyStrict] +includes: [asyncHelpers.js] +info: | + AsyncGeneratorExpression : + async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + +---*/ + +// increment callCount in case "body" +let callCount = 0; +let ref = async function * BindingIdentifier() { + callCount++; + BindingIdentifier = 1; + return BindingIdentifier; +}; + +asyncTest(async () => { + let catchCount = 0; + try { + (await (await ref()).next()).value + } catch (error) { + catchCount++; + assert(error instanceof TypeError); + } + assert.sameValue(catchCount, 1); + assert.sameValue(callCount, 1); +}); + diff --git a/js/src/tests/test262/language/expressions/async-generator/named-unscopables-with-in-nested-fn.js b/js/src/tests/test262/language/expressions/async-generator/named-unscopables-with-in-nested-fn.js new file mode 100644 index 0000000000..f32c2a08de --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-unscopables-with-in-nested-fn.js @@ -0,0 +1,83 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/unscopables-with-in-nested-fn.case +// - src/function-forms/default/async-gen-named-func-expr.template +/*--- +description: Symbol.unscopables behavior across scope boundaries (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [globalThis, Symbol.unscopables, async-iteration] +flags: [generated, noStrict, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + + ... + Let envRec be lex's EnvironmentRecord. + Let exists be ? envRec.HasBinding(name). + + HasBinding + + ... + If the withEnvironment flag of envRec is false, return true. + Let unscopables be ? Get(bindings, @@unscopables). + If Type(unscopables) is Object, then + Let blocked be ToBoolean(? Get(unscopables, N)). + If blocked is true, return false. + + (The `with` Statement) Runtime Semantics: Evaluation + + ... + Set the withEnvironment flag of newEnv’s EnvironmentRecord to true. + ... + +---*/ +let count = 0; +var v = 1; +globalThis[Symbol.unscopables] = { + v: true, +}; + +{ + count++; + + +var callCount = 0; +// Stores a reference `ref` for case evaluation +var ref; +ref = async function* g(x) { + (function() { + count++; + with (globalThis) { + count++; + assert.sameValue(v, 1, 'The value of `v` is 1'); + } + })(); + (function() { + count++; + var v = x; + with (globalThis) { + count++; + assert.sameValue(v, 10, 'The value of `v` is 10'); + v = 20; + } + assert.sameValue(v, 20, 'The value of `v` is 20'); + assert.sameValue(globalThis.v, 1, 'The value of globalThis.v is 1'); + })(); + assert.sameValue(v, 1, 'The value of `v` is 1'); + assert.sameValue(globalThis.v, 1, 'The value of globalThis.v is 1'); + callCount = callCount + 1; +}; + +ref(10).next().then(() => { + assert.sameValue(callCount, 1, 'generator function invoked exactly once'); +}).then($DONE, $DONE); + + count++; +} +assert.sameValue(count, 6, 'The value of `count` is 6'); diff --git a/js/src/tests/test262/language/expressions/async-generator/named-unscopables-with.js b/js/src/tests/test262/language/expressions/async-generator/named-unscopables-with.js new file mode 100644 index 0000000000..1656b3cbc6 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-unscopables-with.js @@ -0,0 +1,77 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/unscopables-with.case +// - src/function-forms/default/async-gen-named-func-expr.template +/*--- +description: Symbol.unscopables behavior across scope boundaries (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [globalThis, Symbol.unscopables, async-iteration] +flags: [generated, noStrict, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + + ... + Let envRec be lex's EnvironmentRecord. + Let exists be ? envRec.HasBinding(name). + + HasBinding + + ... + If the withEnvironment flag of envRec is false, return true. + Let unscopables be ? Get(bindings, @@unscopables). + If Type(unscopables) is Object, then + Let blocked be ToBoolean(? Get(unscopables, N)). + If blocked is true, return false. + + (The `with` Statement) Runtime Semantics: Evaluation + + ... + Set the withEnvironment flag of newEnv’s EnvironmentRecord to true. + ... + +---*/ +let count = 0; +var v = 1; +globalThis[Symbol.unscopables] = { + v: true, +}; + +{ + count++; + + +var callCount = 0; +// Stores a reference `ref` for case evaluation +var ref; +ref = async function* g(x) { + count++; + with (globalThis) { + count++; + assert.sameValue(v, undefined, 'The value of `v` is expected to equal `undefined`'); + } + count++; + var v = x; + with (globalThis) { + count++; + assert.sameValue(v, 10, 'The value of `v` is 10'); + v = 20; + } + assert.sameValue(v, 20, 'The value of `v` is 20'); + assert.sameValue(globalThis.v, 1, 'The value of globalThis.v is 1'); + callCount = callCount + 1; +}; + +ref(10).next().then(() => { + assert.sameValue(callCount, 1, 'generator function invoked exactly once'); +}).then($DONE, $DONE); + + count++; +} +assert.sameValue(count, 6, 'The value of `count` is 6'); diff --git a/js/src/tests/test262/language/expressions/async-generator/named-yield-as-binding-identifier-escaped.js b/js/src/tests/test262/language/expressions/async-generator/named-yield-as-binding-identifier-escaped.js new file mode 100644 index 0000000000..bc6d428325 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-yield-as-binding-identifier-escaped.js @@ -0,0 +1,32 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-as-binding-identifier-escaped.case +// - src/async-generators/syntax/async-expression-named.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + BindingIdentifier : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +$DONOTEVALUATE(); + + +var gen = async function *g() { + var yi\u0065ld; +}; diff --git a/js/src/tests/test262/language/expressions/async-generator/named-yield-as-binding-identifier.js b/js/src/tests/test262/language/expressions/async-generator/named-yield-as-binding-identifier.js new file mode 100644 index 0000000000..7c1f9011cc --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-yield-as-binding-identifier.js @@ -0,0 +1,32 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-as-binding-identifier.case +// - src/async-generators/syntax/async-expression-named.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + BindingIdentifier : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +$DONOTEVALUATE(); + + +var gen = async function *g() { + var yield; +}; diff --git a/js/src/tests/test262/language/expressions/async-generator/named-yield-as-identifier-reference-escaped.js b/js/src/tests/test262/language/expressions/async-generator/named-yield-as-identifier-reference-escaped.js new file mode 100644 index 0000000000..a91e7d984d --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-yield-as-identifier-reference-escaped.js @@ -0,0 +1,32 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-as-identifier-reference-escaped.case +// - src/async-generators/syntax/async-expression-named.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + IdentifierReference : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +$DONOTEVALUATE(); + + +var gen = async function *g() { + void yi\u0065ld; +}; diff --git a/js/src/tests/test262/language/expressions/async-generator/named-yield-as-identifier-reference.js b/js/src/tests/test262/language/expressions/async-generator/named-yield-as-identifier-reference.js new file mode 100644 index 0000000000..9e03c21bca --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-yield-as-identifier-reference.js @@ -0,0 +1,32 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-as-identifier-reference.case +// - src/async-generators/syntax/async-expression-named.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + IdentifierReference : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +$DONOTEVALUATE(); + + +var gen = async function *g() { + void yield; +}; diff --git a/js/src/tests/test262/language/expressions/async-generator/named-yield-as-label-identifier-escaped.js b/js/src/tests/test262/language/expressions/async-generator/named-yield-as-label-identifier-escaped.js new file mode 100644 index 0000000000..77e30f2030 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-yield-as-label-identifier-escaped.js @@ -0,0 +1,32 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-as-label-identifier-escaped.case +// - src/async-generators/syntax/async-expression-named.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as a label identifier. (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + LabelIdentifier : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +$DONOTEVALUATE(); + + +var gen = async function *g() { + yi\u0065ld: ; +}; diff --git a/js/src/tests/test262/language/expressions/async-generator/named-yield-as-label-identifier.js b/js/src/tests/test262/language/expressions/async-generator/named-yield-as-label-identifier.js new file mode 100644 index 0000000000..b4acf9c3b1 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-yield-as-label-identifier.js @@ -0,0 +1,32 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-as-label-identifier.case +// - src/async-generators/syntax/async-expression-named.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as a label identifier. (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + LabelIdentifier : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +$DONOTEVALUATE(); + + +var gen = async function *g() { + yield: ; +}; diff --git a/js/src/tests/test262/language/expressions/async-generator/named-yield-identifier-non-strict.js b/js/src/tests/test262/language/expressions/async-generator/named-yield-identifier-non-strict.js new file mode 100644 index 0000000000..ac8b2ffa0e --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-yield-identifier-non-strict.js @@ -0,0 +1,46 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-identifier-non-strict.case +// - src/async-generators/non-strict/async-expression-named.template +/*--- +description: Use of yield as a valid identifier in a function body inside a generator body in non strict mode (Async generator named expression - valid for non-strict only cases) +esid: prod-AsyncGeneratorExpression +features: [async-iteration] +flags: [generated, noStrict, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + +---*/ + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + return (function(arg) { + var yield = arg + 1; + return yield; + }(yield)) +}; + +var iter = gen(); + +var item = iter.next(); + +item.then(({ done, value }) => { + assert.sameValue(done, false); + assert.sameValue(value, undefined); +}); + +item = iter.next(42); + +item.then(({ done, value }) => { + assert.sameValue(done, true); + assert.sameValue(value, 43); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/named-yield-identifier-spread-non-strict.js b/js/src/tests/test262/language/expressions/async-generator/named-yield-identifier-spread-non-strict.js new file mode 100644 index 0000000000..89894af883 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-yield-identifier-spread-non-strict.js @@ -0,0 +1,64 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-identifier-spread-non-strict.case +// - src/async-generators/non-strict/async-expression-named.template +/*--- +description: Mixed use of object spread and yield as a valid identifier in a function body inside a generator body in non strict mode (Async generator named expression - valid for non-strict only cases) +esid: prod-AsyncGeneratorExpression +features: [object-spread, Symbol, async-iteration] +flags: [generated, noStrict, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + Spread Properties + + PropertyDefinition[Yield]: + (...) + ...AssignmentExpression[In, ?Yield] + +---*/ +var s = Symbol('s'); + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield { + ...yield yield, + ...(function(arg) { + var yield = arg; + return {...yield}; + }(yield)), + ...yield, + } +}; + +var iter = gen(); + +var iter = gen(); + +iter.next(); +iter.next(); +iter.next({ x: 10, a: 0, b: 0, [s]: 1 }); +iter.next({ y: 20, a: 1, b: 1, [s]: 42 }); +var item = iter.next({ z: 30, b: 2 }); + +item.then(({ done, value }) => { + assert.sameValue(done, false); + assert.sameValue(value.x, 10); + assert.sameValue(value.y, 20); + assert.sameValue(value.z, 30); + assert.sameValue(value.a, 1); + assert.sameValue(value.b, 2); + assert.sameValue(value[s], 42); + assert.sameValue(Object.keys(value).length, 5); + assert(Object.prototype.hasOwnProperty.call(value, s), "s is an own property"); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/named-yield-identifier-spread-strict-strict.js b/js/src/tests/test262/language/expressions/async-generator/named-yield-identifier-spread-strict-strict.js new file mode 100644 index 0000000000..1a05d4e18c --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-yield-identifier-spread-strict-strict.js @@ -0,0 +1,48 @@ +// |reftest| error:SyntaxError +'use strict'; +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-identifier-spread-strict.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: It's an early error if the AssignmentExpression is a function body with yield as an identifier in strict mode. (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [object-spread, async-iteration] +flags: [generated, onlyStrict] +negative: + phase: parse + type: SyntaxError +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + Spread Properties + + PropertyDefinition[Yield]: + (...) + ...AssignmentExpression[In, ?Yield] + +---*/ +$DONOTEVALUATE(); + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + return { + ...(function() { + var yield; + throw new Test262Error(); + }()), + } +}; + +var iter = gen(); + + + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/named-yield-identifier-strict-strict.js b/js/src/tests/test262/language/expressions/async-generator/named-yield-identifier-strict-strict.js new file mode 100644 index 0000000000..d621ad6e86 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-yield-identifier-strict-strict.js @@ -0,0 +1,39 @@ +// |reftest| error:SyntaxError +'use strict'; +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-identifier-strict.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: It's an early error if the generator body has another function body with yield as an identifier in strict mode. (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [async-iteration] +flags: [generated, onlyStrict] +negative: + phase: parse + type: SyntaxError +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + +---*/ +$DONOTEVALUATE(); + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + (function() { + var yield; + throw new Test262Error(); + }()) +}; + +var iter = gen(); + + + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/named-yield-promise-reject-next-catch.js b/js/src/tests/test262/language/expressions/async-generator/named-yield-promise-reject-next-catch.js new file mode 100644 index 0000000000..4bdac14bff --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-yield-promise-reject-next-catch.js @@ -0,0 +1,44 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-catch.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: yield Promise.reject(value) is treated as throw value (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + +---*/ +let error = new Error(); + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield Promise.reject(error); + yield "unreachable"; +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}).catch(rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/named-yield-promise-reject-next-for-await-of-async-iterator.js b/js/src/tests/test262/language/expressions/async-generator/named-yield-promise-reject-next-for-await-of-async-iterator.js new file mode 100644 index 0000000000..0a842022b9 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-yield-promise-reject-next-for-await-of-async-iterator.js @@ -0,0 +1,50 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-for-await-of-async-iterator.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: yield * [Promise.reject(value)] is treated as throw value (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + +---*/ +let error = new Error(); +async function * readFile() { + yield Promise.reject(error); + yield "unreachable"; +} + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + for await (let line of readFile()) { + yield line; + } +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/named-yield-promise-reject-next-for-await-of-sync-iterator.js b/js/src/tests/test262/language/expressions/async-generator/named-yield-promise-reject-next-for-await-of-sync-iterator.js new file mode 100644 index 0000000000..ff27edf171 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-yield-promise-reject-next-for-await-of-sync-iterator.js @@ -0,0 +1,49 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-for-await-of-sync-iterator.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: yield Promise.reject(value) in for-await-of is treated as throw value (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + +---*/ +let error = new Error(); +let iterable = [ + Promise.reject(error), + "unreachable" +]; + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + for await (let value of iterable) { + yield value; + } +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/named-yield-promise-reject-next-yield-star-async-iterator.js b/js/src/tests/test262/language/expressions/async-generator/named-yield-promise-reject-next-yield-star-async-iterator.js new file mode 100644 index 0000000000..b1acb22941 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-yield-promise-reject-next-yield-star-async-iterator.js @@ -0,0 +1,48 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-yield-star-async-iterator.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: yield * (async iterator) is treated as throw value (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + +---*/ +let error = new Error(); +async function * readFile() { + yield Promise.reject(error); + yield "unreachable"; +} + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield * readFile(); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}, $DONE).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/named-yield-promise-reject-next-yield-star-sync-iterator.js b/js/src/tests/test262/language/expressions/async-generator/named-yield-promise-reject-next-yield-star-sync-iterator.js new file mode 100644 index 0000000000..615c0251b4 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-yield-promise-reject-next-yield-star-sync-iterator.js @@ -0,0 +1,47 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-yield-star-sync-iterator.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: yield * (async iterator) is treated as throw value (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + +---*/ +let error = new Error(); +let iterable = [ + Promise.reject(error), + "unreachable" +]; + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield * iterable; +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/named-yield-promise-reject-next.js b/js/src/tests/test262/language/expressions/async-generator/named-yield-promise-reject-next.js new file mode 100644 index 0000000000..85ab17c6cd --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-yield-promise-reject-next.js @@ -0,0 +1,44 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: yield Promise.reject(value) is treated as throw value (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + +---*/ +let error = new Error(); + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield Promise.reject(error); + yield "unreachable"; +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/named-yield-spread-arr-multiple.js b/js/src/tests/test262/language/expressions/async-generator/named-yield-spread-arr-multiple.js new file mode 100644 index 0000000000..ddc969ef1e --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-yield-spread-arr-multiple.js @@ -0,0 +1,50 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-spread-arr-multiple.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: Use yield value in a array spread position (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [async-iteration] +flags: [generated, async] +includes: [compareArray.js] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + Array Initializer + + SpreadElement[Yield, Await]: + ...AssignmentExpression[+In, ?Yield, ?Await] + +---*/ +var arr = ['a', 'b', 'c']; +var item; + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield [...yield yield]; +}; + +var iter = gen(); + +iter.next(false); +item = iter.next(['a', 'b', 'c']); + +item.then(({ done, value }) => { + item = iter.next(value); + + item.then(({ done, value }) => { + assert.compareArray(value, arr); + assert.sameValue(done, false); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/named-yield-spread-arr-single.js b/js/src/tests/test262/language/expressions/async-generator/named-yield-spread-arr-single.js new file mode 100644 index 0000000000..52db92dd16 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-yield-spread-arr-single.js @@ -0,0 +1,49 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-spread-arr-single.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: Use yield value in a array spread position (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + Array Initializer + + SpreadElement[Yield, Await]: + ...AssignmentExpression[+In, ?Yield, ?Await] + +---*/ +var arr = ['a', 'b', 'c']; + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield [...yield]; +}; + +var iter = gen(); + +iter.next(false); +var item = iter.next(arr); + +item.then(({ done, value }) => { + assert.notSameValue(value, arr, 'value is a new array'); + assert(Array.isArray(value), 'value is an Array exotic object'); + assert.sameValue(value.length, 3) + assert.sameValue(value[0], 'a'); + assert.sameValue(value[1], 'b'); + assert.sameValue(value[2], 'c'); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/named-yield-spread-obj.js b/js/src/tests/test262/language/expressions/async-generator/named-yield-spread-obj.js new file mode 100644 index 0000000000..3ebc8fa656 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-yield-spread-obj.js @@ -0,0 +1,52 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-spread-obj.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: Use yield value in a object spread position (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [object-spread, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + Spread Properties + + PropertyDefinition[Yield]: + (...) + ...AssignmentExpression[In, ?Yield] + +---*/ + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield { + ...yield, + y: 1, + ...yield yield, + }; +}; + +var iter = gen(); + +iter.next(); +iter.next({ x: 42 }); +iter.next({ x: 'lol' }); +var item = iter.next({ y: 39 }); + +item.then(({ done, value }) => { + assert.sameValue(value.x, 42); + assert.sameValue(value.y, 39); + assert.sameValue(Object.keys(value).length, 2); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/named-yield-star-async-next.js b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-async-next.js new file mode 100644 index 0000000000..904c856d7f --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-async-next.js @@ -0,0 +1,219 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-async-next.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: Execution order for yield* with async iterator and next() (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, async-iteration, Symbol.asyncIterator] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + +---*/ +var log = []; +var obj = { + get [Symbol.iterator]() { + log.push({ name: "get [Symbol.iterator]" }); + }, + get [Symbol.asyncIterator]() { + log.push({ + name: "get [Symbol.asyncIterator]", + thisValue: this + }); + return function() { + log.push({ + name: "call [Symbol.asyncIterator]", + thisValue: this, + args: [...arguments] + }); + var nextCount = 0; + return { + name: "asyncIterator", + get next() { + log.push({ + name: "get next", + thisValue: this + }); + return function() { + log.push({ + name: "call next", + thisValue: this, + args: [...arguments] + }); + + nextCount++; + if (nextCount == 1) { + return { + name: "next-promise-1", + get then() { + log.push({ + name: "get next then (1)", + thisValue: this + }); + return function(resolve) { + log.push({ + name: "call next then (1)", + thisValue: this, + args: [...arguments] + }); + + resolve({ + name: "next-result-1", + get value() { + log.push({ + name: "get next value (1)", + thisValue: this + }); + return "next-value-1"; + }, + get done() { + log.push({ + name: "get next done (1)", + thisValue: this + }); + return false; + } + }); + }; + } + }; + } + + return { + name: "next-promise-2", + get then() { + log.push({ + name: "get next then (2)", + thisValue: this + }); + return function(resolve) { + log.push({ + name: "call next then (2)", + thisValue: this, + args: [...arguments] + }); + + resolve({ + name: "next-result-2", + get value() { + log.push({ + name: "get next value (2)", + thisValue: this + }); + return "next-value-2"; + }, + get done() { + log.push({ + name: "get next done (2)", + thisValue: this + }); + return true; + } + }); + }; + } + }; + }; + } + }; + }; + } +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + log.push({ name: "before yield*" }); + var v = yield* obj; + log.push({ + name: "after yield*", + value: v + }); + return "return-value"; + +}; + +var iter = gen(); + +assert.sameValue(log.length, 0, "log.length"); + +iter.next("next-arg-1").then(v => { + assert.sameValue(log[0].name, "before yield*"); + + assert.sameValue(log[1].name, "get [Symbol.asyncIterator]"); + assert.sameValue(log[1].thisValue, obj, "get [Symbol.asyncIterator] thisValue"); + + assert.sameValue(log[2].name, "call [Symbol.asyncIterator]"); + assert.sameValue(log[2].thisValue, obj, "[Symbol.asyncIterator] thisValue"); + assert.sameValue(log[2].args.length, 0, "[Symbol.asyncIterator] args.length"); + + assert.sameValue(log[3].name, "get next"); + assert.sameValue(log[3].thisValue.name, "asyncIterator", "get next thisValue"); + + assert.sameValue(log[4].name, "call next"); + assert.sameValue(log[4].thisValue.name, "asyncIterator", "next thisValue"); + assert.sameValue(log[4].args.length, 1, "next args.length"); + assert.sameValue(log[4].args[0], undefined, "next args[0]"); + + assert.sameValue(log[5].name, "get next then (1)"); + assert.sameValue(log[5].thisValue.name, "next-promise-1", "get next then thisValue"); + + assert.sameValue(log[6].name, "call next then (1)"); + assert.sameValue(log[6].thisValue.name, "next-promise-1", "next then thisValue"); + assert.sameValue(log[6].args.length, 2, "next then args.length"); + assert.sameValue(typeof log[6].args[0], "function", "next then args[0]"); + assert.sameValue(typeof log[6].args[1], "function", "next then args[1]"); + + assert.sameValue(log[7].name, "get next done (1)"); + assert.sameValue(log[7].thisValue.name, "next-result-1", "get next done thisValue"); + + assert.sameValue(log[8].name, "get next value (1)"); + assert.sameValue(log[8].thisValue.name, "next-result-1", "get next value thisValue"); + + assert.sameValue(v.value, "next-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 9, "log.length"); + + iter.next("next-arg-2").then(v => { + assert.sameValue(log[9].name, "call next"); + assert.sameValue(log[9].thisValue.name, "asyncIterator", "next thisValue"); + assert.sameValue(log[9].args.length, 1, "next args.length"); + assert.sameValue(log[9].args[0], "next-arg-2", "next args[0]"); + + assert.sameValue(log[10].name, "get next then (2)"); + assert.sameValue(log[10].thisValue.name, "next-promise-2", "get next then thisValue"); + + assert.sameValue(log[11].name, "call next then (2)"); + assert.sameValue(log[11].thisValue.name, "next-promise-2", "next then thisValue"); + assert.sameValue(log[11].args.length, 2, "next then args.length"); + assert.sameValue(typeof log[11].args[0], "function", "next then args[0]"); + assert.sameValue(typeof log[11].args[1], "function", "next then args[1]"); + + assert.sameValue(log[12].name, "get next done (2)"); + assert.sameValue(log[12].thisValue.name, "next-result-2", "get next done thisValue"); + + assert.sameValue(log[13].name, "get next value (2)"); + assert.sameValue(log[13].thisValue.name, "next-result-2", "get next value thisValue"); + + assert.sameValue(log[14].name, "after yield*"); + assert.sameValue(log[14].value, "next-value-2"); + + assert.sameValue(v.value, "return-value"); + assert.sameValue(v.done, true); + + assert.sameValue(log.length, 15, "log.length"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/named-yield-star-async-return.js b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-async-return.js new file mode 100644 index 0000000000..4c56c20d31 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-async-return.js @@ -0,0 +1,235 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-async-return.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: execution order for yield* with async iterator and return() (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [async-iteration, Symbol.asyncIterator] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + ... + 6. Repeat + ... + c. Else, + i. Assert: received.[[Type]] is return. + ii. Let return be ? GetMethod(iterator, "return"). + iii. If return is undefined, return Completion(received). + iv. Let innerReturnResult be ? Call(return, iterator, « received.[[Value]] »). + v. If generatorKind is async, then set innerReturnResult to ? Await(innerReturnResult). + ... + vii. Let done be ? IteratorComplete(innerReturnResult). + viii. If done is true, then + 1. Let value be ? IteratorValue(innerReturnResult). + 2. If generatorKind is async, then set value to ? Await(value). + 3. Return Completion{[[Type]]: return, [[Value]]: value, [[Target]]: empty}. + ix. If generatorKind is async, then let received be AsyncGeneratorYield(? IteratorValue(innerResult)). + ... + + AsyncGeneratorYield ( value ) + ... + 8. Return ! AsyncGeneratorResolve(generator, value, false). + ... + +---*/ +var log = []; +var obj = { + [Symbol.asyncIterator]() { + var returnCount = 0; + return { + name: 'asyncIterator', + get next() { + log.push({ name: "get next" }); + return function() { + return { + value: "next-value-1", + done: false + }; + }; + }, + get return() { + log.push({ + name: "get return", + thisValue: this + }); + return function() { + log.push({ + name: "call return", + thisValue: this, + args: [...arguments] + }); + + returnCount++; + if (returnCount == 1) { + return { + name: "return-promise-1", + get then() { + log.push({ + name: "get return then (1)", + thisValue: this + }); + return function(resolve) { + log.push({ + name: "call return then (1)", + thisValue: this, + args: [...arguments] + }); + + resolve({ + name: "return-result-1", + get value() { + log.push({ + name: "get return value (1)", + thisValue: this + }); + return "return-value-1"; + }, + get done() { + log.push({ + name: "get return done (1)", + thisValue: this + }); + return false; + } + }); + }; + } + }; + } + + return { + name: "return-promise-2", + get then() { + log.push({ + name: "get return then (2)", + thisValue: this + }); + return function(resolve) { + log.push({ + name: "call return then (2)", + thisValue: this, + args: [...arguments] + }); + + resolve({ + name: "return-result-2", + get value() { + log.push({ + name: "get return value (2)", + thisValue: this + }); + return "return-value-2"; + }, + get done() { + log.push({ + name: "get return done (2)", + thisValue: this + }); + return true; + } + }); + }; + } + }; + }; + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + log.push({ name: "before yield*" }); + yield* obj; + +}; + +var iter = gen(); + +assert.sameValue(log.length, 0, "log.length"); + +iter.next().then(v => { + assert.sameValue(log[0].name, "before yield*"); + + assert.sameValue(log[1].name, "get next"); + + assert.sameValue(v.value, "next-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 2, "log.length"); + + iter.return("return-arg-1").then(v => { + assert.sameValue(log[2].name, "get return"); + assert.sameValue(log[2].thisValue.name, "asyncIterator", "get return thisValue"); + + assert.sameValue(log[3].name, "call return"); + assert.sameValue(log[3].thisValue.name, "asyncIterator", "return thisValue"); + assert.sameValue(log[3].args.length, 1, "return args.length"); + assert.sameValue(log[3].args[0], "return-arg-1", "return args[0]"); + + assert.sameValue(log[4].name, "get return then (1)"); + assert.sameValue(log[4].thisValue.name, "return-promise-1", "get return then thisValue"); + + assert.sameValue(log[5].name, "call return then (1)"); + assert.sameValue(log[5].thisValue.name, "return-promise-1", "return then thisValue"); + assert.sameValue(log[5].args.length, 2, "return then args.length"); + assert.sameValue(typeof log[5].args[0], "function", "return then args[0]"); + assert.sameValue(typeof log[5].args[1], "function", "return then args[1]"); + + assert.sameValue(log[6].name, "get return done (1)"); + assert.sameValue(log[6].thisValue.name, "return-result-1", "get return done thisValue"); + + assert.sameValue(log[7].name, "get return value (1)"); + assert.sameValue(log[7].thisValue.name, "return-result-1", "get return value thisValue"); + + assert.sameValue(v.value, "return-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 8, "log.length"); + + iter.return("return-arg-2").then(v => { + assert.sameValue(log[8].name, "get return"); + assert.sameValue(log[8].thisValue.name, "asyncIterator", "get return thisValue"); + + assert.sameValue(log[9].name, "call return"); + assert.sameValue(log[9].thisValue.name, "asyncIterator", "return thisValue"); + assert.sameValue(log[9].args.length, 1, "return args.length"); + assert.sameValue(log[9].args[0], "return-arg-2", "return args[0]"); + + assert.sameValue(log[10].name, "get return then (2)"); + assert.sameValue(log[10].thisValue.name, "return-promise-2", "get return then thisValue"); + + assert.sameValue(log[11].name, "call return then (2)"); + assert.sameValue(log[11].thisValue.name, "return-promise-2", "return then thisValue"); + assert.sameValue(log[11].args.length, 2, "return then args.length"); + assert.sameValue(typeof log[11].args[0], "function", "return then args[0]"); + assert.sameValue(typeof log[11].args[1], "function", "return then args[1]"); + + assert.sameValue(log[12].name, "get return done (2)"); + assert.sameValue(log[12].thisValue.name, "return-result-2", "get return done thisValue"); + + assert.sameValue(log[13].name, "get return value (2)"); + assert.sameValue(log[13].thisValue.name, "return-result-2", "get return value thisValue"); + + assert.sameValue(v.value, "return-value-2"); + assert.sameValue(v.done, true); + + assert.sameValue(log.length, 14, "log.length"); + }).then($DONE, $DONE); + }).catch($DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/named-yield-star-async-throw.js b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-async-throw.js new file mode 100644 index 0000000000..87d3da4090 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-async-throw.js @@ -0,0 +1,243 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-async-throw.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: execution order for yield* with async iterator and throw() (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [async-iteration, Symbol.asyncIterator] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + ... + 6. Repeat + ... + b. Else if received.[[Type]] is throw, then + i. Let throw be ? GetMethod(iterator, "throw"). + ii. If throw is not undefined, then + 1. Let innerResult be ? Call(throw, iterator, « received.[[Value]] »). + 2. If generatorKind is async, then set innerResult to ? Await(innerResult). + ... + 5. Let done be ? IteratorComplete(innerResult). + 6. If done is true, then + a. Let resultValue be Return ? IteratorValue(innerResult). + b. If generatorKind is async, then set resultValue to ? Await(resultValue). + c. Return resultValue. + 7. If generatorKind is async, then let received be AsyncGeneratorYield(? IteratorValue(innerResult)). + ... + + AsyncGeneratorYield ( value ) + + ... + 8. Return ! AsyncGeneratorResolve(generator, value, false). + ... + +---*/ +var log = []; +var obj = { + [Symbol.asyncIterator]() { + var throwCount = 0; + return { + name: "asyncIterator", + get next() { + log.push({ name: "get next" }); + return function() { + return { + value: "next-value-1", + done: false + }; + }; + }, + get throw() { + log.push({ + name: "get throw", + thisValue: this + }); + return function() { + log.push({ + name: "call throw", + thisValue: this, + args: [...arguments] + }); + + throwCount++; + if (throwCount == 1) { + return { + name: "throw-promise-1", + get then() { + log.push({ + name: "get throw then (1)", + thisValue: this + }); + return function(resolve) { + log.push({ + name: "call throw then (1)", + thisValue: this, + args: [...arguments] + }); + + resolve({ + name: "throw-result-1", + get value() { + log.push({ + name: "get throw value (1)", + thisValue: this + }); + return "throw-value-1"; + }, + get done() { + log.push({ + name: "get throw done (1)", + thisValue: this + }); + return false; + } + }); + }; + } + }; + } + + return { + name: "throw-promise-2", + get then() { + log.push({ + name: "get throw then (2)", + thisValue: this + }); + return function(resolve) { + log.push({ + name: "call throw then (2)", + thisValue: this, + args: [...arguments] + }); + + resolve({ + name: "throw-result-2", + get value() { + log.push({ + name: "get throw value (2)", + thisValue: this + }); + return "throw-value-2"; + }, + get done() { + log.push({ + name: "get throw done (2)", + thisValue: this + }); + return true; + } + }); + }; + } + }; + }; + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + log.push({ name: "before yield*" }); + var v = yield* obj; + log.push({ + name: "after yield*", + value: v + }); + return "return-value"; + +}; + +var iter = gen(); + +assert.sameValue(log.length, 0, "log.length"); + +iter.next().then(v => { + assert.sameValue(log[0].name, "before yield*"); + + assert.sameValue(log[1].name, "get next"); + + assert.sameValue(v.value, "next-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 2, "log.length"); + + iter.throw("throw-arg-1").then(v => { + assert.sameValue(log[2].name, "get throw"); + assert.sameValue(log[2].thisValue.name, "asyncIterator", "get throw thisValue"); + + assert.sameValue(log[3].name, "call throw"); + assert.sameValue(log[3].thisValue.name, "asyncIterator", "throw thisValue"); + assert.sameValue(log[3].args.length, 1, "throw args.length"); + assert.sameValue(log[3].args[0], "throw-arg-1", "throw args[0]"); + + assert.sameValue(log[4].name, "get throw then (1)"); + assert.sameValue(log[4].thisValue.name, "throw-promise-1", "get throw thisValue"); + + assert.sameValue(log[5].name, "call throw then (1)"); + assert.sameValue(log[5].thisValue.name, "throw-promise-1", "throw thisValue"); + assert.sameValue(log[5].args.length, 2, "throw then args.length"); + assert.sameValue(typeof log[5].args[0], "function", "throw then args[0]"); + assert.sameValue(typeof log[5].args[1], "function", "throw then args[1]"); + + assert.sameValue(log[6].name, "get throw done (1)"); + assert.sameValue(log[6].thisValue.name, "throw-result-1", "get throw done thisValue"); + + assert.sameValue(log[7].name, "get throw value (1)"); + assert.sameValue(log[7].thisValue.name, "throw-result-1", "get throw value thisValue"); + + assert.sameValue(v.value, "throw-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 8, "log.length"); + + iter.throw("throw-arg-2").then(v => { + assert.sameValue(log[8].name, "get throw"); + assert.sameValue(log[8].thisValue.name, "asyncIterator", "get throw thisValue"); + + assert.sameValue(log[9].name, "call throw"); + assert.sameValue(log[9].thisValue.name, "asyncIterator", "throw thisValue"); + assert.sameValue(log[9].args.length, 1, "throw args.length"); + assert.sameValue(log[9].args[0], "throw-arg-2", "throw args[0]"); + + assert.sameValue(log[10].name, "get throw then (2)"); + assert.sameValue(log[10].thisValue.name, "throw-promise-2", "get throw thisValue"); + + assert.sameValue(log[11].name, "call throw then (2)"); + assert.sameValue(log[11].thisValue.name, "throw-promise-2", "throw thisValue"); + assert.sameValue(log[11].args.length, 2, "throw then args.length"); + assert.sameValue(typeof log[11].args[0], "function", "throw then args[0]"); + assert.sameValue(typeof log[11].args[1], "function", "throw then args[1]"); + + assert.sameValue(log[12].name, "get throw done (2)"); + assert.sameValue(log[12].thisValue.name, "throw-result-2", "get throw done thisValue"); + + assert.sameValue(log[13].name, "get throw value (2)"); + assert.sameValue(log[13].thisValue.name, "throw-result-2", "get throw value thisValue"); + + assert.sameValue(log[14].name, "after yield*"); + assert.sameValue(log[14].value, "throw-value-2"); + + assert.sameValue(v.value, "return-value"); + assert.sameValue(v.done, true); + + assert.sameValue(log.length, 15, "log.length"); + }).then($DONE, $DONE); + }).catch($DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/named-yield-star-expr-abrupt.js b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-expr-abrupt.js new file mode 100644 index 0000000000..4a28cca3db --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-expr-abrupt.js @@ -0,0 +1,54 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-expr-abrupt.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: Abrupt completion while getting yield* operand (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + ... + +---*/ +var obj = {}; +var abrupt = function() { + throw obj; +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* abrupt(); + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, obj, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/named-yield-star-getiter-async-get-abrupt.js b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-getiter-async-get-abrupt.js new file mode 100644 index 0000000000..2d0300fa3c --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-getiter-async-get-abrupt.js @@ -0,0 +1,74 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-get-abrupt.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: Abrupt completion while getting [Symbol.asyncIterator] (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + get [Symbol.asyncIterator]() { + throw reason; + } +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/named-yield-star-getiter-async-not-callable-boolean-throw.js b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-getiter-async-not-callable-boolean-throw.js new file mode 100644 index 0000000000..931d2763b7 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-getiter-async-not-callable-boolean-throw.js @@ -0,0 +1,73 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-not-callable-boolean-throw.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.asyncIterator] (boolean) (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + 3. If func is either undefined or null, return undefined. + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]: false +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/named-yield-star-getiter-async-not-callable-number-throw.js b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-getiter-async-not-callable-number-throw.js new file mode 100644 index 0000000000..087a62f01e --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-getiter-async-not-callable-number-throw.js @@ -0,0 +1,73 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-not-callable-number-throw.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.asyncIterator] (number) (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + 3. If func is either undefined or null, return undefined. + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]: 0 +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/named-yield-star-getiter-async-not-callable-object-throw.js b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-getiter-async-not-callable-object-throw.js new file mode 100644 index 0000000000..d8dc7764a7 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-getiter-async-not-callable-object-throw.js @@ -0,0 +1,73 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-not-callable-object-throw.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.asyncIterator] (object) (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + 3. If func is either undefined or null, return undefined. + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]: {} +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/named-yield-star-getiter-async-not-callable-string-throw.js b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-getiter-async-not-callable-string-throw.js new file mode 100644 index 0000000000..162bbdd077 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-getiter-async-not-callable-string-throw.js @@ -0,0 +1,73 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-not-callable-string-throw.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.asyncIterator] (string) (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + 3. If func is either undefined or null, return undefined. + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]: '' +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/named-yield-star-getiter-async-not-callable-symbol-throw.js b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-getiter-async-not-callable-symbol-throw.js new file mode 100644 index 0000000000..239b0de71b --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-getiter-async-not-callable-symbol-throw.js @@ -0,0 +1,73 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-not-callable-symbol-throw.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.asyncIterator] (symbol) (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + 3. If func is either undefined or null, return undefined. + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]: Symbol.asyncIterator +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/named-yield-star-getiter-async-null-sync-get-abrupt.js b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-getiter-async-null-sync-get-abrupt.js new file mode 100644 index 0000000000..d65a282855 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-getiter-async-null-sync-get-abrupt.js @@ -0,0 +1,79 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-null-sync-get-abrupt.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: Abrupt completion while getting @@iterator after null @@asyncIterator (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + +---*/ +var calls = 0; +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw reason; + }, + get [Symbol.asyncIterator]() { + calls += 1; + return null; + } +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, 'reject reason'); + assert.sameValue(calls, 1); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/named-yield-star-getiter-async-returns-abrupt.js b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-getiter-async-returns-abrupt.js new file mode 100644 index 0000000000..d210513355 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-getiter-async-returns-abrupt.js @@ -0,0 +1,70 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-returns-abrupt.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: Abrupt completion while calling [Symbol.asyncIterator] (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + 6. Let iterator be ? Call(method, obj). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + throw reason; + } +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/named-yield-star-getiter-async-returns-boolean-throw.js b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-getiter-async-returns-boolean-throw.js new file mode 100644 index 0000000000..1cd251b3b9 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-getiter-async-returns-boolean-throw.js @@ -0,0 +1,70 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-returns-boolean-throw.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: Non object returned by [Symbol.asyncIterator]() - boolean (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + 6. Let iterator be ? Call(method, obj). + 7. If Type(iterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return true; + } +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/named-yield-star-getiter-async-returns-null-throw.js b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-getiter-async-returns-null-throw.js new file mode 100644 index 0000000000..fd65d73653 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-getiter-async-returns-null-throw.js @@ -0,0 +1,70 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-returns-null-throw.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: Non object returned by [Symbol.asyncIterator]() - null (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + 6. Let iterator be ? Call(method, obj). + 7. If Type(iterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return null; + } +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/named-yield-star-getiter-async-returns-number-throw.js b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-getiter-async-returns-number-throw.js new file mode 100644 index 0000000000..2eb11f2b2a --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-getiter-async-returns-number-throw.js @@ -0,0 +1,70 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-returns-number-throw.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: Non object returned by [Symbol.asyncIterator]() - number (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + 6. Let iterator be ? Call(method, obj). + 7. If Type(iterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return 42; + } +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/named-yield-star-getiter-async-returns-string-throw.js b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-getiter-async-returns-string-throw.js new file mode 100644 index 0000000000..76cfafb451 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-getiter-async-returns-string-throw.js @@ -0,0 +1,70 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-returns-string-throw.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: Non object returned by [Symbol.asyncIterator]() - string (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + 6. Let iterator be ? Call(method, obj). + 7. If Type(iterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return '42'; + } +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/named-yield-star-getiter-async-returns-symbol-throw.js b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-getiter-async-returns-symbol-throw.js new file mode 100644 index 0000000000..8ea4928706 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-getiter-async-returns-symbol-throw.js @@ -0,0 +1,70 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-returns-symbol-throw.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: Non object returned by [Symbol.asyncIterator]() - symbol (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + 6. Let iterator be ? Call(method, obj). + 7. If Type(iterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return Symbol.asyncIterator; + } +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/named-yield-star-getiter-async-returns-undefined-throw.js b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-getiter-async-returns-undefined-throw.js new file mode 100644 index 0000000000..5ab7266b49 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-getiter-async-returns-undefined-throw.js @@ -0,0 +1,70 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-returns-undefined-throw.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: Non object returned by [Symbol.asyncIterator]() - undefined (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + 6. Let iterator be ? Call(method, obj). + 7. If Type(iterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return undefined; + } +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/named-yield-star-getiter-async-undefined-sync-get-abrupt.js b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-getiter-async-undefined-sync-get-abrupt.js new file mode 100644 index 0000000000..25c3966324 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-getiter-async-undefined-sync-get-abrupt.js @@ -0,0 +1,79 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-undefined-sync-get-abrupt.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: Abrupt completion while getting @@iterator after undefined @@asyncIterator (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + +---*/ +var calls = 0; +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw reason; + }, + get [Symbol.asyncIterator]() { + calls += 1; + return undefined; + } +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, 'reject reason'); + assert.sameValue(calls, 1); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/named-yield-star-getiter-sync-get-abrupt.js b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-getiter-sync-get-abrupt.js new file mode 100644 index 0000000000..efcfbbf402 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-getiter-sync-get-abrupt.js @@ -0,0 +1,73 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-get-abrupt.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: Abrupt completion while getting [Symbol.iterator] (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw reason; + } +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/named-yield-star-getiter-sync-not-callable-boolean-throw.js b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-getiter-sync-not-callable-boolean-throw.js new file mode 100644 index 0000000000..48a010d224 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-getiter-sync-not-callable-boolean-throw.js @@ -0,0 +1,72 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-not-callable-boolean-throw.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.iterator] (boolean) (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]: false +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/named-yield-star-getiter-sync-not-callable-number-throw.js b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-getiter-sync-not-callable-number-throw.js new file mode 100644 index 0000000000..f987249e10 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-getiter-sync-not-callable-number-throw.js @@ -0,0 +1,72 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-not-callable-number-throw.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.iterator] (number) (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]: 0 +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/named-yield-star-getiter-sync-not-callable-object-throw.js b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-getiter-sync-not-callable-object-throw.js new file mode 100644 index 0000000000..a35d12ecb7 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-getiter-sync-not-callable-object-throw.js @@ -0,0 +1,72 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-not-callable-object-throw.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.iterator] (object) (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]: {} +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/named-yield-star-getiter-sync-not-callable-string-throw.js b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-getiter-sync-not-callable-string-throw.js new file mode 100644 index 0000000000..fb7056aeb0 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-getiter-sync-not-callable-string-throw.js @@ -0,0 +1,72 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-not-callable-string-throw.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.iterator] (string) (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]: '' +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/named-yield-star-getiter-sync-not-callable-symbol-throw.js b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-getiter-sync-not-callable-symbol-throw.js new file mode 100644 index 0000000000..4aac649946 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-getiter-sync-not-callable-symbol-throw.js @@ -0,0 +1,72 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-not-callable-symbol-throw.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.iterator] (symbol) (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]: Symbol.iterator +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/named-yield-star-getiter-sync-returns-abrupt.js b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-getiter-sync-returns-abrupt.js new file mode 100644 index 0000000000..9052274aaf --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-getiter-sync-returns-abrupt.js @@ -0,0 +1,67 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-returns-abrupt.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: Abrupt completion while calling [Symbol.iterator] (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + ... + +---*/ +var reason = {}; +var obj = { + [Symbol.iterator]() { + throw reason; + } +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/named-yield-star-getiter-sync-returns-boolean-throw.js b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-getiter-sync-returns-boolean-throw.js new file mode 100644 index 0000000000..e4ca23f728 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-getiter-sync-returns-boolean-throw.js @@ -0,0 +1,72 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-returns-boolean-throw.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: Non object returned by [Symbol.iterator]() - boolean (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + iii. Return ? CreateAsyncFromSyncIterator(syncIterator). + ... + + CreateAsyncFromSyncIterator(syncIterator) + + 1. If Type(syncIterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]() { + return true; + } +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/named-yield-star-getiter-sync-returns-null-throw.js b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-getiter-sync-returns-null-throw.js new file mode 100644 index 0000000000..f6c22f9aeb --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-getiter-sync-returns-null-throw.js @@ -0,0 +1,72 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-returns-null-throw.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: Non object returned by [Symbol.iterator]() - null (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + iii. Return ? CreateAsyncFromSyncIterator(syncIterator). + ... + + CreateAsyncFromSyncIterator(syncIterator) + + 1. If Type(syncIterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]() { + return null; + } +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/named-yield-star-getiter-sync-returns-number-throw.js b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-getiter-sync-returns-number-throw.js new file mode 100644 index 0000000000..e9777aa6f4 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-getiter-sync-returns-number-throw.js @@ -0,0 +1,72 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-returns-number-throw.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: Non object returned by [Symbol.iterator]() - number (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + iii. Return ? CreateAsyncFromSyncIterator(syncIterator). + ... + + CreateAsyncFromSyncIterator(syncIterator) + + 1. If Type(syncIterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]() { + return 0; + } +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/named-yield-star-getiter-sync-returns-string-throw.js b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-getiter-sync-returns-string-throw.js new file mode 100644 index 0000000000..c58d7874f2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-getiter-sync-returns-string-throw.js @@ -0,0 +1,72 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-returns-string-throw.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: Non object returned by [Symbol.iterator]() - string (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + iii. Return ? CreateAsyncFromSyncIterator(syncIterator). + ... + + CreateAsyncFromSyncIterator(syncIterator) + + 1. If Type(syncIterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]() { + return ''; + } +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/named-yield-star-getiter-sync-returns-symbol-throw.js b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-getiter-sync-returns-symbol-throw.js new file mode 100644 index 0000000000..fea53d164b --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-getiter-sync-returns-symbol-throw.js @@ -0,0 +1,72 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-returns-symbol-throw.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: Non object returned by [Symbol.iterator]() - symbol (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + iii. Return ? CreateAsyncFromSyncIterator(syncIterator). + ... + + CreateAsyncFromSyncIterator(syncIterator) + + 1. If Type(syncIterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]() { + return Symbol.iterator; + } +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/named-yield-star-getiter-sync-returns-undefined-throw.js b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-getiter-sync-returns-undefined-throw.js new file mode 100644 index 0000000000..5c11a72ea0 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-getiter-sync-returns-undefined-throw.js @@ -0,0 +1,72 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-returns-undefined-throw.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: Non object returned by [Symbol.iterator]() - undefined (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + iii. Return ? CreateAsyncFromSyncIterator(syncIterator). + ... + + CreateAsyncFromSyncIterator(syncIterator) + + 1. If Type(syncIterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]() { + return undefined; + } +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/named-yield-star-next-call-done-get-abrupt.js b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-next-call-done-get-abrupt.js new file mode 100644 index 0000000000..0f111bb149 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-next-call-done-get-abrupt.js @@ -0,0 +1,73 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-call-done-get-abrupt.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: Abrupt completion while getting done (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + v. Let done be ? IteratorComplete(innerResult). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + get done() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/named-yield-star-next-call-returns-abrupt.js b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-next-call-returns-abrupt.js new file mode 100644 index 0000000000..87744633df --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-next-call-returns-abrupt.js @@ -0,0 +1,65 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-call-returns-abrupt.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: Abrupt completion while calling next (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + throw reason; + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/named-yield-star-next-call-value-get-abrupt.js b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-next-call-value-get-abrupt.js new file mode 100644 index 0000000000..ffc74aec9b --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-next-call-value-get-abrupt.js @@ -0,0 +1,75 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-call-value-get-abrupt.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: Abrupt completion while getting value (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + vi. If done is true, then + 1. Return ? IteratorValue(innerResult). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + done: true, + get value() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/named-yield-star-next-get-abrupt.js b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-next-get-abrupt.js new file mode 100644 index 0000000000..e731e31103 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-next-get-abrupt.js @@ -0,0 +1,65 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-get-abrupt.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: Abrupt completion while getting next (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + get next() { + throw reason; + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/named-yield-star-next-non-object-ignores-then.js b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-next-non-object-ignores-then.js new file mode 100644 index 0000000000..0051905a6b --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-next-non-object-ignores-then.js @@ -0,0 +1,85 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-non-object-ignores-then.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: If next() value is not-object, do not access respective then property (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + +---*/ +Number.prototype.then = function() { + throw new Test262Error('Number#then should not be used'); +}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return 42; + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, 'TypeError'); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/named-yield-star-next-not-callable-boolean-throw.js b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-next-not-callable-boolean-throw.js new file mode 100644 index 0000000000..64076a393c --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-next-not-callable-boolean-throw.js @@ -0,0 +1,62 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-boolean-throw.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: Not-callable next value in a yield star position - boolean (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: true + }; + } +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/named-yield-star-next-not-callable-null-throw.js b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-next-not-callable-null-throw.js new file mode 100644 index 0000000000..f31869aca3 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-next-not-callable-null-throw.js @@ -0,0 +1,62 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-null-throw.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: Not-callable next value in a yield star position - null (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: null + }; + } +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/named-yield-star-next-not-callable-number-throw.js b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-next-not-callable-number-throw.js new file mode 100644 index 0000000000..b94fad4ed0 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-next-not-callable-number-throw.js @@ -0,0 +1,62 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-number-throw.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: Not-callable next value in a yield star position - number (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: 42 + }; + } +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/named-yield-star-next-not-callable-object-throw.js b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-next-not-callable-object-throw.js new file mode 100644 index 0000000000..3dbcfe3777 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-next-not-callable-object-throw.js @@ -0,0 +1,62 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-object-throw.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: Not-callable next value in a yield star position - object (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: {} + }; + } +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/named-yield-star-next-not-callable-string-throw.js b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-next-not-callable-string-throw.js new file mode 100644 index 0000000000..2374798265 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-next-not-callable-string-throw.js @@ -0,0 +1,62 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-string-throw.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: Not-callable next value in a yield star position - string (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: '' + }; + } +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/named-yield-star-next-not-callable-symbol-throw.js b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-next-not-callable-symbol-throw.js new file mode 100644 index 0000000000..a93dbe7353 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-next-not-callable-symbol-throw.js @@ -0,0 +1,62 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-symbol-throw.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: Not-callable next value in a yield star position - symbol (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: Symbol('oi') + }; + } +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/named-yield-star-next-not-callable-undefined-throw.js b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-next-not-callable-undefined-throw.js new file mode 100644 index 0000000000..78bd90aa14 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-next-not-callable-undefined-throw.js @@ -0,0 +1,62 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-undefined-throw.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: Not-callable next value in a yield star position - undefined (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: undefined + }; + } +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/named-yield-star-next-then-get-abrupt.js b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-next-then-get-abrupt.js new file mode 100644 index 0000000000..ceb021d277 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-next-then-get-abrupt.js @@ -0,0 +1,89 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-get-abrupt.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: Return abrupt after getting next().then (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 8. Let then be Get(resolution, "then"). + ... + 10. Get thenAction be then.[[Value]]. + ... + 12. Perform EnqueueJob("PromiseJobs", PromiseResolveThenableJob, « promise, + resolution, thenAction »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + get then() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, 'reject reason'); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/named-yield-star-next-then-non-callable-boolean-fulfillpromise.js b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-next-then-non-callable-boolean-fulfillpromise.js new file mode 100644 index 0000000000..d077cceb47 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-next-then-non-callable-boolean-fulfillpromise.js @@ -0,0 +1,83 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-boolean-fulfillpromise.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: FulfillPromise if next().then is not-callable (boolean) (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: true, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/named-yield-star-next-then-non-callable-null-fulfillpromise.js b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-next-then-non-callable-null-fulfillpromise.js new file mode 100644 index 0000000000..a05a88a2a1 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-next-then-non-callable-null-fulfillpromise.js @@ -0,0 +1,83 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-null-fulfillpromise.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: FulfillPromise if next().then is not-callable (null) (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: null, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/named-yield-star-next-then-non-callable-number-fulfillpromise.js b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-next-then-non-callable-number-fulfillpromise.js new file mode 100644 index 0000000000..dc2cfde595 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-next-then-non-callable-number-fulfillpromise.js @@ -0,0 +1,83 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-number-fulfillpromise.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: FulfillPromise if next().then is not-callable (number) (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: 39, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/named-yield-star-next-then-non-callable-object-fulfillpromise.js b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-next-then-non-callable-object-fulfillpromise.js new file mode 100644 index 0000000000..9437c9fe3e --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-next-then-non-callable-object-fulfillpromise.js @@ -0,0 +1,83 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-object-fulfillpromise.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: FulfillPromise if next().then is not-callable (object) (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: {}, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/named-yield-star-next-then-non-callable-string-fulfillpromise.js b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-next-then-non-callable-string-fulfillpromise.js new file mode 100644 index 0000000000..160cb63722 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-next-then-non-callable-string-fulfillpromise.js @@ -0,0 +1,83 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-string-fulfillpromise.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: FulfillPromise if next().then is not-callable (string) (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: '', + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/named-yield-star-next-then-non-callable-symbol-fulfillpromise.js b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-next-then-non-callable-symbol-fulfillpromise.js new file mode 100644 index 0000000000..8d2a6446d2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-next-then-non-callable-symbol-fulfillpromise.js @@ -0,0 +1,83 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-symbol-fulfillpromise.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: FulfillPromise if next().then is not-callable (symbol) (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: Symbol('oi'), + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/named-yield-star-next-then-non-callable-undefined-fulfillpromise.js b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-next-then-non-callable-undefined-fulfillpromise.js new file mode 100644 index 0000000000..43c41e8349 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-next-then-non-callable-undefined-fulfillpromise.js @@ -0,0 +1,83 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-undefined-fulfillpromise.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: FulfillPromise if next().then is not-callable (undefined) (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: undefined, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/named-yield-star-next-then-returns-abrupt.js b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-next-then-returns-abrupt.js new file mode 100644 index 0000000000..405bc63761 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-next-then-returns-abrupt.js @@ -0,0 +1,89 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-returns-abrupt.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: Return abrupt after calling next().then (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 8. Let then be Get(resolution, "then"). + ... + 10. Get thenAction be then.[[Value]]. + ... + 12. Perform EnqueueJob("PromiseJobs", PromiseResolveThenableJob, « promise, + resolution, thenAction »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, 'reject reason'); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/named-yield-star-sync-next.js b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-sync-next.js new file mode 100644 index 0000000000..f8e09c51be --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-sync-next.js @@ -0,0 +1,222 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-sync-next.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: execution order for yield* with sync iterator and next() (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, async-iteration, Symbol.asyncIterator] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + ... + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + 5. Let received be NormalCompletion(undefined). + 6. Repeat + a. If received.[[Type]] is normal, then + i. Let innerResult be ? IteratorNext(iterator, received.[[Value]]). + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + v. Let done be ? IteratorComplete(innerResult). + vi. If done is true, then + 1. Return ? IteratorValue(innerResult). + vii. Let received be GeneratorYield(innerResult). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + iii. Return ? CreateAsyncFromSyncIterator(syncIterator). + ... + + %AsyncFromSyncIteratorPrototype%.next ( value ) + + ... + 5. Let nextResult be IteratorNext(syncIterator, value). + ... + 7. Let nextValue be IteratorValue(nextResult). + ... + 9. Let nextDone be IteratorComplete(nextResult). + ... + 12. Perform ! Call(valueWrapperCapability.[[Resolve]], undefined, + « nextValue »). + ... + 14. Set onFulfilled.[[Done]] to nextDone. + 15. Perform ! PerformPromiseThen(valueWrapperCapability.[[Promise]], + onFulfilled, undefined, promiseCapability). + ... + + Async Iterator Value Unwrap Functions + + 1. Return ! CreateIterResultObject(value, F.[[Done]]). + +---*/ +var log = []; +var obj = { + get [Symbol.iterator]() { + log.push({ + name: "get [Symbol.iterator]", + thisValue: this + }); + return function() { + log.push({ + name: "call [Symbol.iterator]", + thisValue: this, + args: [...arguments] + }); + var nextCount = 0; + return { + name: "syncIterator", + get next() { + log.push({ + name: "get next", + thisValue: this + }); + return function() { + log.push({ + name: "call next", + thisValue: this, + args: [...arguments] + }); + + nextCount++; + if (nextCount == 1) { + return { + name: "next-result-1", + get value() { + log.push({ + name: "get next value (1)", + thisValue: this + }); + return "next-value-1"; + }, + get done() { + log.push({ + name: "get next done (1)", + thisValue: this + }); + return false; + } + }; + } + + return { + name: "next-result-2", + get value() { + log.push({ + name: "get next value (2)", + thisValue: this + }); + return "next-value-2"; + }, + get done() { + log.push({ + name: "get next done (2)", + thisValue: this + }); + return true; + } + }; + }; + } + }; + }; + }, + get [Symbol.asyncIterator]() { + log.push({ name: "get [Symbol.asyncIterator]" }); + return null; + } +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + log.push({ name: "before yield*" }); + var v = yield* obj; + log.push({ + name: "after yield*", + value: v + }); + return "return-value"; + +}; + +var iter = gen(); + +assert.sameValue(log.length, 0, "log.length"); + +iter.next("next-arg-1").then(v => { + assert.sameValue(log[0].name, "before yield*"); + + assert.sameValue(log[1].name, "get [Symbol.asyncIterator]"); + + assert.sameValue(log[2].name, "get [Symbol.iterator]"); + assert.sameValue(log[2].thisValue, obj, "get [Symbol.iterator] thisValue"); + + assert.sameValue(log[3].name, "call [Symbol.iterator]"); + assert.sameValue(log[3].thisValue, obj, "[Symbol.iterator] thisValue"); + assert.sameValue(log[3].args.length, 0, "[Symbol.iterator] args.length"); + + assert.sameValue(log[4].name, "get next"); + assert.sameValue(log[4].thisValue.name, "syncIterator", "get next thisValue"); + + assert.sameValue(log[5].name, "call next"); + assert.sameValue(log[5].thisValue.name, "syncIterator", "next thisValue"); + assert.sameValue(log[5].args.length, 1, "next args.length"); + assert.sameValue(log[5].args[0], undefined, "next args[0]"); + + assert.sameValue(log[6].name, "get next done (1)"); + assert.sameValue(log[6].thisValue.name, "next-result-1", "get next done thisValue"); + + assert.sameValue(log[7].name, "get next value (1)"); + assert.sameValue(log[7].thisValue.name, "next-result-1", "get next value thisValue"); + + assert.sameValue(v.value, "next-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 8, "log.length"); + + iter.next("next-arg-2").then(v => { + assert.sameValue(log[8].name, "call next"); + assert.sameValue(log[8].thisValue.name, "syncIterator", "next thisValue"); + assert.sameValue(log[8].args.length, 1, "next args.length"); + assert.sameValue(log[8].args[0], "next-arg-2", "next args[0]"); + + assert.sameValue(log[9].name, "get next done (2)"); + assert.sameValue(log[9].thisValue.name, "next-result-2", "get next done thisValue"); + + assert.sameValue(log[10].name, "get next value (2)"); + assert.sameValue(log[10].thisValue.name, "next-result-2", "get next value thisValue"); + + assert.sameValue(log[11].name, "after yield*"); + assert.sameValue(log[11].value, "next-value-2"); + + assert.sameValue(v.value, "return-value"); + assert.sameValue(v.done, true); + + assert.sameValue(log.length, 12, "log.length"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/named-yield-star-sync-return.js b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-sync-return.js new file mode 100644 index 0000000000..55f649a41c --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-sync-return.js @@ -0,0 +1,197 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-sync-return.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: execution order for yield* with sync iterator and return() (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, async-iteration, Symbol.asyncIterator] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + ... + 6. Repeat + ... + c. Else, + i. Assert: received.[[Type]] is return. + ii. Let return be ? GetMethod(iterator, "return"). + iii. If return is undefined, return Completion(received). + iv. Let innerReturnResult be ? Call(return, iterator, + « received.[[Value]] »). + v. If generatorKind is async, then set innerReturnResult to + ? Await(innerReturnResult). + ... + vii. Let done be ? IteratorComplete(innerReturnResult). + viii. If done is true, then + 1. Let value be ? IteratorValue(innerReturnResult). + 2. Return Completion{[[Type]]: return, [[Value]]: value, + [[Target]]: empty}. + ix. Let received be GeneratorYield(innerResult). + + %AsyncFromSyncIteratorPrototype%.return ( value ) + + 5. Let return be GetMethod(syncIterator, "return"). + ... + ... + 8. Let returnResult be Call(return, syncIterator, « value »). + ... + 11. Let returnValue be IteratorValue(returnResult). + .. + 13. Let returnDone be IteratorComplete(returnResult). + ... + 16. Perform ! Call(valueWrapperCapability.[[Resolve]], undefined, « returnValue »). + ... + 18. Set onFulfilled.[[Done]] to returnDone. + 19. Perform ! PerformPromiseThen(valueWrapperCapability.[[Promise]], + onFulfilled, undefined, promiseCapability). + ... + +---*/ +var log = []; +var obj = { + [Symbol.iterator]() { + var returnCount = 0; + return { + name: "syncIterator", + get next() { + log.push({ name: "get next" }); + return function() { + return { + value: "next-value-1", + done: false + }; + }; + }, + get return() { + log.push({ + name: "get return", + thisValue: this + }); + return function() { + log.push({ + name: "call return", + thisValue: this, + args: [...arguments] + }); + + returnCount++; + if (returnCount == 1) { + return { + name: "return-result-1", + get value() { + log.push({ + name: "get return value (1)", + thisValue: this + }); + return "return-value-1"; + }, + get done() { + log.push({ + name: "get return done (1)", + thisValue: this + }); + return false; + } + }; + } + + return { + name: "return-result-2", + get value() { + log.push({ + name: "get return value (2)", + thisValue: this + }); + return "return-value-2"; + }, + get done() { + log.push({ + name: "get return done (2)", + thisValue: this + }); + return true; + } + }; + }; + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + log.push({ name: "before yield*" }); + yield* obj; + +}; + +var iter = gen(); + +assert.sameValue(log.length, 0, "log.length"); + +iter.next().then(v => { + assert.sameValue(log[0].name, "before yield*"); + + assert.sameValue(log[1].name, "get next"); + + assert.sameValue(v.value, "next-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 2, "log.length"); + + iter.return("return-arg-1").then(v => { + assert.sameValue(log[2].name, "get return"); + assert.sameValue(log[2].thisValue.name, "syncIterator", "get return thisValue"); + + assert.sameValue(log[3].name, "call return"); + assert.sameValue(log[3].thisValue.name, "syncIterator", "return thisValue"); + assert.sameValue(log[3].args.length, 1, "return args.length"); + assert.sameValue(log[3].args[0], "return-arg-1", "return args[0]"); + + assert.sameValue(log[4].name, "get return done (1)"); + assert.sameValue(log[4].thisValue.name, "return-result-1", "get return done thisValue"); + + assert.sameValue(log[5].name, "get return value (1)"); + assert.sameValue(log[5].thisValue.name, "return-result-1", "get return value thisValue"); + + assert.sameValue(v.value, "return-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 6, "log.length"); + + iter.return().then(v => { + assert.sameValue(log[6].name, "get return"); + assert.sameValue(log[6].thisValue.name, "syncIterator", "get return thisValue"); + + assert.sameValue(log[7].name, "call return"); + assert.sameValue(log[7].thisValue.name, "syncIterator", "get return thisValue"); + assert.sameValue(log[7].args.length, 1, "return args.length"); + assert.sameValue(log[7].args[0], undefined, "return args[0]"); + + assert.sameValue(log[8].name, "get return done (2)"); + assert.sameValue(log[8].thisValue.name, "return-result-2", "get return done thisValue"); + + assert.sameValue(log[9].name, "get return value (2)"); + assert.sameValue(log[9].thisValue.name, "return-result-2", "get return value thisValue"); + + assert.sameValue(v.value, "return-value-2"); + assert.sameValue(v.done, true); + + assert.sameValue(log.length, 10, "log.length"); + }).then($DONE, $DONE); + }).catch($DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/named-yield-star-sync-throw.js b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-sync-throw.js new file mode 100644 index 0000000000..431199311e --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/named-yield-star-sync-throw.js @@ -0,0 +1,203 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-sync-throw.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: execution order for yield* with sync iterator and throw() (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + ... + 6. Repeat + ... + b. Else if received.[[Type]] is throw, then + i. Let throw be ? GetMethod(iterator, "throw"). + ii. If throw is not undefined, then + 1. Let innerResult be ? Call(throw, iterator, « received.[[Value]] »). + 2. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + 5. Let done be ? IteratorComplete(innerResult). + 6. If done is true, then + a. Return ? IteratorValue(innerResult). + 7. Let received be GeneratorYield(innerResult). + ... + + %AsyncFromSyncIteratorPrototype%.throw ( value ) + + ... + 5. Let throw be GetMethod(syncIterator, "throw"). + ... + 8. Let throwResult be Call(throw, syncIterator, « value »). + ... + 11. Let throwValue be IteratorValue(throwResult). + ... + 13. Let throwDone be IteratorComplete(throwResult). + ... + 16. Perform ! Call(valueWrapperCapability.[[Resolve]], undefined, + « throwValue »). + ... + 18. Set onFulfilled.[[Done]] to throwDone. + 19. Perform ! PerformPromiseThen(valueWrapperCapability.[[Promise]], + onFulfilled, undefined, promiseCapability). + ... + +---*/ +var log = []; +var obj = { + [Symbol.iterator]() { + var throwCount = 0; + return { + name: "syncIterator", + get next() { + log.push({ name: "get next" }); + return function() { + return { + value: "next-value-1", + done: false + }; + }; + }, + get throw() { + log.push({ + name: "get throw", + thisValue: this + }); + return function() { + log.push({ + name: "call throw", + thisValue: this, + args: [...arguments] + }); + + throwCount++; + if (throwCount == 1) { + return { + name: "throw-result-1", + get value() { + log.push({ + name: "get throw value (1)", + thisValue: this + }); + return "throw-value-1"; + }, + get done() { + log.push({ + name: "get throw done (1)", + thisValue: this + }); + return false; + } + }; + } + + return { + name: "throw-result-2", + get value() { + log.push({ + name: "get throw value (2)", + thisValue: this + }); + return "throw-value-2"; + }, + get done() { + log.push({ + name: "get throw done (2)", + thisValue: this + }); + return true; + } + }; + }; + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + log.push({ name: "before yield*" }); + var v = yield* obj; + log.push({ + name: "after yield*", + value: v + }); + return "return-value"; + +}; + +var iter = gen(); + +assert.sameValue(log.length, 0, "log.length"); + +iter.next().then(v => { + assert.sameValue(log[0].name, "before yield*"); + + assert.sameValue(log[1].name, "get next"); + + assert.sameValue(v.value, "next-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 2, "log.length"); + + iter.throw("throw-arg-1").then(v => { + assert.sameValue(log[2].name, "get throw"); + assert.sameValue(log[2].thisValue.name, "syncIterator", "get throw thisValue"); + + assert.sameValue(log[3].name, "call throw"); + assert.sameValue(log[3].thisValue.name, "syncIterator", "throw thisValue"); + assert.sameValue(log[3].args.length, 1, "throw args.length"); + assert.sameValue(log[3].args[0], "throw-arg-1", "throw args[0]"); + + assert.sameValue(log[4].name, "get throw done (1)"); + assert.sameValue(log[4].thisValue.name, "throw-result-1", "get throw done thisValue"); + + assert.sameValue(log[5].name, "get throw value (1)"); + assert.sameValue(log[5].thisValue.name, "throw-result-1", "get throw value thisValue"); + + assert.sameValue(v.value, "throw-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 6, "log.length"); + + iter.throw().then(v => { + assert.sameValue(log[6].name, "get throw"); + assert.sameValue(log[6].thisValue.name, "syncIterator", "get throw thisValue"); + + assert.sameValue(log[7].name, "call throw"); + assert.sameValue(log[7].thisValue.name, "syncIterator", "throw thisValue"); + assert.sameValue(log[7].args.length, 1, "throw args.length"); + assert.sameValue(log[7].args[0], undefined, "throw args[0]"); + + assert.sameValue(log[8].name, "get throw done (2)"); + assert.sameValue(log[8].thisValue.name, "throw-result-2", "get throw done thisValue"); + + assert.sameValue(log[9].name, "get throw value (2)"); + assert.sameValue(log[9].thisValue.name, "throw-result-2", "get throw value thisValue"); + + assert.sameValue(log[10].name, "after yield*"); + assert.sameValue(log[10].value, "throw-value-2"); + + assert.sameValue(v.value, "return-value"); + assert.sameValue(v.done, true); + + assert.sameValue(log.length, 11, "log.length"); + }).then($DONE, $DONE); + }).catch($DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/object-destructuring-param-strict-body.js b/js/src/tests/test262/language/expressions/async-generator/object-destructuring-param-strict-body.js new file mode 100644 index 0000000000..98ffca1da1 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/object-destructuring-param-strict-body.js @@ -0,0 +1,113 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/object-destructuring-param-strict-body.case +// - src/function-forms/syntax/async-gen-func-expr.template +/*--- +description: ObjectBindingPattern and Use Strict Directive are not allowed to coexist for the same function. (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [rest-parameters, async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.4 Static Semantics: IsSimpleParameterList + + BindingElement : BindingPattern + + 1. Return false. + + 14.1.2 Static Semantics: Early Errors + + FunctionDeclaration : function BindingIdentifier ( FormalParameters ) { FunctionBody } + FunctionDeclaration : function ( FormalParameters ) { FunctionBody } + FunctionExpression : function BindingIdentifier ( FormalParameters ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.2.1 Static Semantics: Early Errors + + ArrowFunction : ArrowParameters => ConciseBody + + - It is a Syntax Error if ContainsUseStrict of ConciseBody is true and + IsSimpleParameterList of ArrowParameters is false. + + 14.3.1 Static Semantics: Early Errors + + MethodDefinition : PropertyName ( UniqueFormalParameters ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + MethodDefinition : set PropertyName ( PropertySetParameterList ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of PropertySetParameterList is false. + + 14.4.1 Static Semantics: Early Errors + + GeneratorMethod : * PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of GeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + GeneratorDeclaration : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + GeneratorExpression : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of GeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + 14.5.1 Static Semantics: Early Errors + + AsyncGeneratorMethod : async * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncGeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + AsyncGeneratorDeclaration : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + AsyncGeneratorDeclaration : async function * ( FormalParameters ) { AsyncGeneratorBody } + AsyncGeneratorExpression : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncGeneratorBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.7.1 Static Semantics: Early Errors + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncFunctionBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + AsyncFunctionDeclaration : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionDeclaration : async function ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionExpression : async function ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionExpression : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncFunctionBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.8.1 Static Semantics: Early Errors + + AsyncArrowFunction : CoverCallExpressionAndAsyncArrowHead => AsyncConciseBody + + - It is a Syntax Error if ContainsUseStrict of AsyncConciseBody is true and + IsSimpleParameterList of CoverCallExpressionAndAsyncArrowHead is false. + +---*/ +$DONOTEVALUATE(); + + +0, async function*({property}) { + "use strict"; +}; diff --git a/js/src/tests/test262/language/expressions/async-generator/params-trailing-comma-multiple.js b/js/src/tests/test262/language/expressions/async-generator/params-trailing-comma-multiple.js new file mode 100644 index 0000000000..4420b0920c --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/params-trailing-comma-multiple.js @@ -0,0 +1,41 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/params-trailing-comma-multiple.case +// - src/function-forms/default/async-gen-func-expr.template +/*--- +description: A trailing comma should not increase the respective length, using multiple parameters (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + Trailing comma in the parameters list + + 14.1 Function Definitions + + FormalParameters[Yield, Await] : FormalParameterList[?Yield, ?Await] , +---*/ + + +var callCount = 0; +// Stores a reference `ref` for case evaluation +var ref; +ref = async function*(a, b,) { + assert.sameValue(a, 42); + assert.sameValue(b, 39); + callCount = callCount + 1; +}; + +ref(42, 39, 1).next().then(() => { + assert.sameValue(callCount, 1, 'generator function invoked exactly once'); +}).then($DONE, $DONE); + +assert.sameValue(ref.length, 2, 'length is properly set'); diff --git a/js/src/tests/test262/language/expressions/async-generator/params-trailing-comma-single.js b/js/src/tests/test262/language/expressions/async-generator/params-trailing-comma-single.js new file mode 100644 index 0000000000..9b6b8e373c --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/params-trailing-comma-single.js @@ -0,0 +1,40 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/params-trailing-comma-single.case +// - src/function-forms/default/async-gen-func-expr.template +/*--- +description: A trailing comma should not increase the respective length, using a single parameter (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + Trailing comma in the parameters list + + 14.1 Function Definitions + + FormalParameters[Yield, Await] : FormalParameterList[?Yield, ?Await] , +---*/ + + +var callCount = 0; +// Stores a reference `ref` for case evaluation +var ref; +ref = async function*(a,) { + assert.sameValue(a, 42); + callCount = callCount + 1; +}; + +ref(42, 39).next().then(() => { + assert.sameValue(callCount, 1, 'generator function invoked exactly once'); +}).then($DONE, $DONE); + +assert.sameValue(ref.length, 1, 'length is properly set'); diff --git a/js/src/tests/test262/language/expressions/async-generator/rest-param-strict-body.js b/js/src/tests/test262/language/expressions/async-generator/rest-param-strict-body.js new file mode 100644 index 0000000000..e65fd4f7c6 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/rest-param-strict-body.js @@ -0,0 +1,113 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/rest-param-strict-body.case +// - src/function-forms/syntax/async-gen-func-expr.template +/*--- +description: RestParameter and Use Strict Directive are not allowed to coexist for the same function. (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [rest-parameters, async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 14.1.13 Static Semantics: IsSimpleParameterList + + FormalParameters : FormalParameterList , FunctionRestParameter + + 1. Return false. + + 14.1.2 Static Semantics: Early Errors + + FunctionDeclaration : function BindingIdentifier ( FormalParameters ) { FunctionBody } + FunctionDeclaration : function ( FormalParameters ) { FunctionBody } + FunctionExpression : function BindingIdentifier ( FormalParameters ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.2.1 Static Semantics: Early Errors + + ArrowFunction : ArrowParameters => ConciseBody + + - It is a Syntax Error if ContainsUseStrict of ConciseBody is true and + IsSimpleParameterList of ArrowParameters is false. + + 14.3.1 Static Semantics: Early Errors + + MethodDefinition : PropertyName ( UniqueFormalParameters ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + MethodDefinition : set PropertyName ( PropertySetParameterList ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of PropertySetParameterList is false. + + 14.4.1 Static Semantics: Early Errors + + GeneratorMethod : * PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of GeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + GeneratorDeclaration : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + GeneratorExpression : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of GeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + 14.5.1 Static Semantics: Early Errors + + AsyncGeneratorMethod : async * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncGeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + AsyncGeneratorDeclaration : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + AsyncGeneratorDeclaration : async function * ( FormalParameters ) { AsyncGeneratorBody } + AsyncGeneratorExpression : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncGeneratorBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.7.1 Static Semantics: Early Errors + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncFunctionBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + AsyncFunctionDeclaration : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionDeclaration : async function ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionExpression : async function ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionExpression : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncFunctionBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.8.1 Static Semantics: Early Errors + + AsyncArrowFunction : CoverCallExpressionAndAsyncArrowHead => AsyncConciseBody + + - It is a Syntax Error if ContainsUseStrict of AsyncConciseBody is true and + IsSimpleParameterList of CoverCallExpressionAndAsyncArrowHead is false. + +---*/ +$DONOTEVALUATE(); + + +0, async function*(a,...rest) { + "use strict"; +}; diff --git a/js/src/tests/test262/language/expressions/async-generator/rest-params-trailing-comma-early-error.js b/js/src/tests/test262/language/expressions/async-generator/rest-params-trailing-comma-early-error.js new file mode 100644 index 0000000000..d0ab701557 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/rest-params-trailing-comma-early-error.js @@ -0,0 +1,39 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/rest-params-trailing-comma-early-error.case +// - src/function-forms/syntax/async-gen-func-expr.template +/*--- +description: It's a syntax error if a FunctionRestParameter is followed by a trailing comma (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + Trailing comma in the parameters list + + 14.1 Function Definitions + + FormalParameters[Yield, Await] : + [empty] + FunctionRestParameter[?Yield, ?Await] + FormalParameterList[?Yield, ?Await] + FormalParameterList[?Yield, ?Await] , + FormalParameterList[?Yield, ?Await] , FunctionRestParameter[?Yield, ?Await] +---*/ +$DONOTEVALUATE(); + + +0, async function*(...a,) { + +}; diff --git a/js/src/tests/test262/language/expressions/async-generator/shell.js b/js/src/tests/test262/language/expressions/async-generator/shell.js new file mode 100644 index 0000000000..cf5a381e81 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/shell.js @@ -0,0 +1,137 @@ +// GENERATED, DO NOT EDIT +// file: asyncHelpers.js +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: | + A collection of assertion and wrapper functions for testing asynchronous built-ins. +defines: [asyncTest] +---*/ + +function asyncTest(testFunc) { + if (!Object.hasOwn(globalThis, "$DONE")) { + throw new Test262Error("asyncTest called without async flag"); + } + if (typeof testFunc !== "function") { + $DONE(new Test262Error("asyncTest called with non-function argument")); + return; + } + try { + testFunc().then( + function () { + $DONE(); + }, + function (error) { + $DONE(error); + } + ); + } catch (syncError) { + $DONE(syncError); + } +} + +assert.throwsAsync = async function (expectedErrorConstructor, func, message) { + var innerThenable; + if (message === undefined) { + message = ""; + } else { + message += " "; + } + if (typeof func === "function") { + try { + innerThenable = func(); + if ( + innerThenable === null || + typeof innerThenable !== "object" || + typeof innerThenable.then !== "function" + ) { + message += + "Expected to obtain an inner promise that would reject with a" + + expectedErrorConstructor.name + + " but result was not a thenable"; + throw new Test262Error(message); + } + } catch (thrown) { + message += + "Expected a " + + expectedErrorConstructor.name + + " to be thrown asynchronously but an exception was thrown synchronously while obtaining the inner promise"; + throw new Test262Error(message); + } + } else { + message += + "assert.throwsAsync called with an argument that is not a function"; + throw new Test262Error(message); + } + + try { + return innerThenable.then( + function () { + message += + "Expected a " + + expectedErrorConstructor.name + + " to be thrown asynchronously but no exception was thrown at all"; + throw new Test262Error(message); + }, + function (thrown) { + var expectedName, actualName; + if (typeof thrown !== "object" || thrown === null) { + message += "Thrown value was not an object!"; + throw new Test262Error(message); + } else if (thrown.constructor !== expectedErrorConstructor) { + expectedName = expectedErrorConstructor.name; + actualName = thrown.constructor.name; + if (expectedName === actualName) { + message += + "Expected a " + + expectedName + + " but got a different error constructor with the same name"; + } else { + message += + "Expected a " + expectedName + " but got a " + actualName; + } + throw new Test262Error(message); + } + } + ); + } catch (thrown) { + if (typeof thrown !== "object" || thrown === null) { + message += + "Expected a " + + expectedErrorConstructor.name + + " to be thrown asynchronously but innerThenable synchronously threw a value that was not an object "; + } else { + message += + "Expected a " + + expectedErrorConstructor.name + + " to be thrown asynchronously but a " + + thrown.constructor.name + + " was thrown synchronously"; + } + throw new Test262Error(message); + } +}; + +// file: isConstructor.js +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: | + Test if a given function is a constructor function. +defines: [isConstructor] +features: [Reflect.construct] +---*/ + +function isConstructor(f) { + if (typeof f !== "function") { + throw new Test262Error("isConstructor invoked with a non-function value"); + } + + try { + Reflect.construct(function(){}, [], f); + } catch (e) { + return false; + } + return true; +} diff --git a/js/src/tests/test262/language/expressions/async-generator/unscopables-with-in-nested-fn.js b/js/src/tests/test262/language/expressions/async-generator/unscopables-with-in-nested-fn.js new file mode 100644 index 0000000000..fb34ee1120 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/unscopables-with-in-nested-fn.js @@ -0,0 +1,83 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/unscopables-with-in-nested-fn.case +// - src/function-forms/default/async-gen-func-expr.template +/*--- +description: Symbol.unscopables behavior across scope boundaries (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [globalThis, Symbol.unscopables, async-iteration] +flags: [generated, noStrict, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + ... + Let envRec be lex's EnvironmentRecord. + Let exists be ? envRec.HasBinding(name). + + HasBinding + + ... + If the withEnvironment flag of envRec is false, return true. + Let unscopables be ? Get(bindings, @@unscopables). + If Type(unscopables) is Object, then + Let blocked be ToBoolean(? Get(unscopables, N)). + If blocked is true, return false. + + (The `with` Statement) Runtime Semantics: Evaluation + + ... + Set the withEnvironment flag of newEnv’s EnvironmentRecord to true. + ... + +---*/ +let count = 0; +var v = 1; +globalThis[Symbol.unscopables] = { + v: true, +}; + +{ + count++; + + +var callCount = 0; +// Stores a reference `ref` for case evaluation +var ref; +ref = async function*(x) { + (function() { + count++; + with (globalThis) { + count++; + assert.sameValue(v, 1, 'The value of `v` is 1'); + } + })(); + (function() { + count++; + var v = x; + with (globalThis) { + count++; + assert.sameValue(v, 10, 'The value of `v` is 10'); + v = 20; + } + assert.sameValue(v, 20, 'The value of `v` is 20'); + assert.sameValue(globalThis.v, 1, 'The value of globalThis.v is 1'); + })(); + assert.sameValue(v, 1, 'The value of `v` is 1'); + assert.sameValue(globalThis.v, 1, 'The value of globalThis.v is 1'); + callCount = callCount + 1; +}; + +ref(10).next().then(() => { + assert.sameValue(callCount, 1, 'generator function invoked exactly once'); +}).then($DONE, $DONE); + + count++; +} +assert.sameValue(count, 6, 'The value of `count` is 6'); diff --git a/js/src/tests/test262/language/expressions/async-generator/unscopables-with.js b/js/src/tests/test262/language/expressions/async-generator/unscopables-with.js new file mode 100644 index 0000000000..c81b74fc1d --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/unscopables-with.js @@ -0,0 +1,77 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/unscopables-with.case +// - src/function-forms/default/async-gen-func-expr.template +/*--- +description: Symbol.unscopables behavior across scope boundaries (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [globalThis, Symbol.unscopables, async-iteration] +flags: [generated, noStrict, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + ... + Let envRec be lex's EnvironmentRecord. + Let exists be ? envRec.HasBinding(name). + + HasBinding + + ... + If the withEnvironment flag of envRec is false, return true. + Let unscopables be ? Get(bindings, @@unscopables). + If Type(unscopables) is Object, then + Let blocked be ToBoolean(? Get(unscopables, N)). + If blocked is true, return false. + + (The `with` Statement) Runtime Semantics: Evaluation + + ... + Set the withEnvironment flag of newEnv’s EnvironmentRecord to true. + ... + +---*/ +let count = 0; +var v = 1; +globalThis[Symbol.unscopables] = { + v: true, +}; + +{ + count++; + + +var callCount = 0; +// Stores a reference `ref` for case evaluation +var ref; +ref = async function*(x) { + count++; + with (globalThis) { + count++; + assert.sameValue(v, undefined, 'The value of `v` is expected to equal `undefined`'); + } + count++; + var v = x; + with (globalThis) { + count++; + assert.sameValue(v, 10, 'The value of `v` is 10'); + v = 20; + } + assert.sameValue(v, 20, 'The value of `v` is 20'); + assert.sameValue(globalThis.v, 1, 'The value of globalThis.v is 1'); + callCount = callCount + 1; +}; + +ref(10).next().then(() => { + assert.sameValue(callCount, 1, 'generator function invoked exactly once'); +}).then($DONE, $DONE); + + count++; +} +assert.sameValue(count, 6, 'The value of `count` is 6'); diff --git a/js/src/tests/test262/language/expressions/async-generator/yield-as-binding-identifier-escaped.js b/js/src/tests/test262/language/expressions/async-generator/yield-as-binding-identifier-escaped.js new file mode 100644 index 0000000000..1b7a3d5c70 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/yield-as-binding-identifier-escaped.js @@ -0,0 +1,32 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-as-binding-identifier-escaped.case +// - src/async-generators/syntax/async-expression.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + BindingIdentifier : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +$DONOTEVALUATE(); + + +var gen = async function *() { + var yi\u0065ld; +}; diff --git a/js/src/tests/test262/language/expressions/async-generator/yield-as-binding-identifier.js b/js/src/tests/test262/language/expressions/async-generator/yield-as-binding-identifier.js new file mode 100644 index 0000000000..b83d30181e --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/yield-as-binding-identifier.js @@ -0,0 +1,32 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-as-binding-identifier.case +// - src/async-generators/syntax/async-expression.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + BindingIdentifier : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +$DONOTEVALUATE(); + + +var gen = async function *() { + var yield; +}; diff --git a/js/src/tests/test262/language/expressions/async-generator/yield-as-identifier-reference-escaped.js b/js/src/tests/test262/language/expressions/async-generator/yield-as-identifier-reference-escaped.js new file mode 100644 index 0000000000..f03c691dce --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/yield-as-identifier-reference-escaped.js @@ -0,0 +1,32 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-as-identifier-reference-escaped.case +// - src/async-generators/syntax/async-expression.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + IdentifierReference : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +$DONOTEVALUATE(); + + +var gen = async function *() { + void yi\u0065ld; +}; diff --git a/js/src/tests/test262/language/expressions/async-generator/yield-as-identifier-reference.js b/js/src/tests/test262/language/expressions/async-generator/yield-as-identifier-reference.js new file mode 100644 index 0000000000..3db9c366ce --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/yield-as-identifier-reference.js @@ -0,0 +1,32 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-as-identifier-reference.case +// - src/async-generators/syntax/async-expression.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + IdentifierReference : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +$DONOTEVALUATE(); + + +var gen = async function *() { + void yield; +}; diff --git a/js/src/tests/test262/language/expressions/async-generator/yield-as-label-identifier-escaped.js b/js/src/tests/test262/language/expressions/async-generator/yield-as-label-identifier-escaped.js new file mode 100644 index 0000000000..918c83ca7c --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/yield-as-label-identifier-escaped.js @@ -0,0 +1,32 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-as-label-identifier-escaped.case +// - src/async-generators/syntax/async-expression.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as a label identifier. (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + LabelIdentifier : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +$DONOTEVALUATE(); + + +var gen = async function *() { + yi\u0065ld: ; +}; diff --git a/js/src/tests/test262/language/expressions/async-generator/yield-as-label-identifier.js b/js/src/tests/test262/language/expressions/async-generator/yield-as-label-identifier.js new file mode 100644 index 0000000000..581fd97828 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/yield-as-label-identifier.js @@ -0,0 +1,32 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-as-label-identifier.case +// - src/async-generators/syntax/async-expression.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as a label identifier. (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + LabelIdentifier : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +$DONOTEVALUATE(); + + +var gen = async function *() { + yield: ; +}; diff --git a/js/src/tests/test262/language/expressions/async-generator/yield-identifier-non-strict.js b/js/src/tests/test262/language/expressions/async-generator/yield-identifier-non-strict.js new file mode 100644 index 0000000000..6109ef68dd --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/yield-identifier-non-strict.js @@ -0,0 +1,46 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-identifier-non-strict.case +// - src/async-generators/non-strict/async-expression.template +/*--- +description: Use of yield as a valid identifier in a function body inside a generator body in non strict mode (Async generator expression - valid for non-strict only cases) +esid: prod-AsyncGeneratorExpression +features: [async-iteration] +flags: [generated, noStrict, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + +---*/ + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + return (function(arg) { + var yield = arg + 1; + return yield; + }(yield)) +}; + +var iter = gen(); + +var item = iter.next(); + +item.then(({ done, value }) => { + assert.sameValue(done, false); + assert.sameValue(value, undefined); +}); + +item = iter.next(42); + +item.then(({ done, value }) => { + assert.sameValue(done, true); + assert.sameValue(value, 43); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/yield-identifier-spread-non-strict.js b/js/src/tests/test262/language/expressions/async-generator/yield-identifier-spread-non-strict.js new file mode 100644 index 0000000000..07db53e691 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/yield-identifier-spread-non-strict.js @@ -0,0 +1,64 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-identifier-spread-non-strict.case +// - src/async-generators/non-strict/async-expression.template +/*--- +description: Mixed use of object spread and yield as a valid identifier in a function body inside a generator body in non strict mode (Async generator expression - valid for non-strict only cases) +esid: prod-AsyncGeneratorExpression +features: [object-spread, Symbol, async-iteration] +flags: [generated, noStrict, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + Spread Properties + + PropertyDefinition[Yield]: + (...) + ...AssignmentExpression[In, ?Yield] + +---*/ +var s = Symbol('s'); + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield { + ...yield yield, + ...(function(arg) { + var yield = arg; + return {...yield}; + }(yield)), + ...yield, + } +}; + +var iter = gen(); + +var iter = gen(); + +iter.next(); +iter.next(); +iter.next({ x: 10, a: 0, b: 0, [s]: 1 }); +iter.next({ y: 20, a: 1, b: 1, [s]: 42 }); +var item = iter.next({ z: 30, b: 2 }); + +item.then(({ done, value }) => { + assert.sameValue(done, false); + assert.sameValue(value.x, 10); + assert.sameValue(value.y, 20); + assert.sameValue(value.z, 30); + assert.sameValue(value.a, 1); + assert.sameValue(value.b, 2); + assert.sameValue(value[s], 42); + assert.sameValue(Object.keys(value).length, 5); + assert(Object.prototype.hasOwnProperty.call(value, s), "s is an own property"); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/yield-identifier-spread-strict-strict.js b/js/src/tests/test262/language/expressions/async-generator/yield-identifier-spread-strict-strict.js new file mode 100644 index 0000000000..80d10cb584 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/yield-identifier-spread-strict-strict.js @@ -0,0 +1,48 @@ +// |reftest| error:SyntaxError +'use strict'; +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-identifier-spread-strict.case +// - src/async-generators/default/async-expression.template +/*--- +description: It's an early error if the AssignmentExpression is a function body with yield as an identifier in strict mode. (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [object-spread, async-iteration] +flags: [generated, onlyStrict] +negative: + phase: parse + type: SyntaxError +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + Spread Properties + + PropertyDefinition[Yield]: + (...) + ...AssignmentExpression[In, ?Yield] + +---*/ +$DONOTEVALUATE(); + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + return { + ...(function() { + var yield; + throw new Test262Error(); + }()), + } +}; + +var iter = gen(); + + + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/yield-identifier-strict-strict.js b/js/src/tests/test262/language/expressions/async-generator/yield-identifier-strict-strict.js new file mode 100644 index 0000000000..619b331edf --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/yield-identifier-strict-strict.js @@ -0,0 +1,39 @@ +// |reftest| error:SyntaxError +'use strict'; +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-identifier-strict.case +// - src/async-generators/default/async-expression.template +/*--- +description: It's an early error if the generator body has another function body with yield as an identifier in strict mode. (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [async-iteration] +flags: [generated, onlyStrict] +negative: + phase: parse + type: SyntaxError +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + +---*/ +$DONOTEVALUATE(); + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + (function() { + var yield; + throw new Test262Error(); + }()) +}; + +var iter = gen(); + + + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/yield-promise-reject-next-catch.js b/js/src/tests/test262/language/expressions/async-generator/yield-promise-reject-next-catch.js new file mode 100644 index 0000000000..c6bc275429 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/yield-promise-reject-next-catch.js @@ -0,0 +1,44 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-catch.case +// - src/async-generators/default/async-expression.template +/*--- +description: yield Promise.reject(value) is treated as throw value (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + +---*/ +let error = new Error(); + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield Promise.reject(error); + yield "unreachable"; +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}).catch(rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/yield-promise-reject-next-for-await-of-async-iterator.js b/js/src/tests/test262/language/expressions/async-generator/yield-promise-reject-next-for-await-of-async-iterator.js new file mode 100644 index 0000000000..b52d02c782 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/yield-promise-reject-next-for-await-of-async-iterator.js @@ -0,0 +1,50 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-for-await-of-async-iterator.case +// - src/async-generators/default/async-expression.template +/*--- +description: yield * [Promise.reject(value)] is treated as throw value (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + +---*/ +let error = new Error(); +async function * readFile() { + yield Promise.reject(error); + yield "unreachable"; +} + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + for await (let line of readFile()) { + yield line; + } +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/yield-promise-reject-next-for-await-of-sync-iterator.js b/js/src/tests/test262/language/expressions/async-generator/yield-promise-reject-next-for-await-of-sync-iterator.js new file mode 100644 index 0000000000..63c5e9d729 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/yield-promise-reject-next-for-await-of-sync-iterator.js @@ -0,0 +1,49 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-for-await-of-sync-iterator.case +// - src/async-generators/default/async-expression.template +/*--- +description: yield Promise.reject(value) in for-await-of is treated as throw value (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + +---*/ +let error = new Error(); +let iterable = [ + Promise.reject(error), + "unreachable" +]; + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + for await (let value of iterable) { + yield value; + } +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/yield-promise-reject-next-yield-star-async-iterator.js b/js/src/tests/test262/language/expressions/async-generator/yield-promise-reject-next-yield-star-async-iterator.js new file mode 100644 index 0000000000..56dbf03163 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/yield-promise-reject-next-yield-star-async-iterator.js @@ -0,0 +1,48 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-yield-star-async-iterator.case +// - src/async-generators/default/async-expression.template +/*--- +description: yield * (async iterator) is treated as throw value (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + +---*/ +let error = new Error(); +async function * readFile() { + yield Promise.reject(error); + yield "unreachable"; +} + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield * readFile(); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}, $DONE).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/yield-promise-reject-next-yield-star-sync-iterator.js b/js/src/tests/test262/language/expressions/async-generator/yield-promise-reject-next-yield-star-sync-iterator.js new file mode 100644 index 0000000000..4894df5495 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/yield-promise-reject-next-yield-star-sync-iterator.js @@ -0,0 +1,47 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-yield-star-sync-iterator.case +// - src/async-generators/default/async-expression.template +/*--- +description: yield * (async iterator) is treated as throw value (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + +---*/ +let error = new Error(); +let iterable = [ + Promise.reject(error), + "unreachable" +]; + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield * iterable; +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/yield-promise-reject-next.js b/js/src/tests/test262/language/expressions/async-generator/yield-promise-reject-next.js new file mode 100644 index 0000000000..0d1b1e641e --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/yield-promise-reject-next.js @@ -0,0 +1,44 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next.case +// - src/async-generators/default/async-expression.template +/*--- +description: yield Promise.reject(value) is treated as throw value (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + +---*/ +let error = new Error(); + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield Promise.reject(error); + yield "unreachable"; +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/yield-spread-arr-multiple.js b/js/src/tests/test262/language/expressions/async-generator/yield-spread-arr-multiple.js new file mode 100644 index 0000000000..4dbf565258 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/yield-spread-arr-multiple.js @@ -0,0 +1,50 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-spread-arr-multiple.case +// - src/async-generators/default/async-expression.template +/*--- +description: Use yield value in a array spread position (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [async-iteration] +flags: [generated, async] +includes: [compareArray.js] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + Array Initializer + + SpreadElement[Yield, Await]: + ...AssignmentExpression[+In, ?Yield, ?Await] + +---*/ +var arr = ['a', 'b', 'c']; +var item; + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield [...yield yield]; +}; + +var iter = gen(); + +iter.next(false); +item = iter.next(['a', 'b', 'c']); + +item.then(({ done, value }) => { + item = iter.next(value); + + item.then(({ done, value }) => { + assert.compareArray(value, arr); + assert.sameValue(done, false); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/yield-spread-arr-single.js b/js/src/tests/test262/language/expressions/async-generator/yield-spread-arr-single.js new file mode 100644 index 0000000000..fbec5ea757 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/yield-spread-arr-single.js @@ -0,0 +1,49 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-spread-arr-single.case +// - src/async-generators/default/async-expression.template +/*--- +description: Use yield value in a array spread position (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + Array Initializer + + SpreadElement[Yield, Await]: + ...AssignmentExpression[+In, ?Yield, ?Await] + +---*/ +var arr = ['a', 'b', 'c']; + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield [...yield]; +}; + +var iter = gen(); + +iter.next(false); +var item = iter.next(arr); + +item.then(({ done, value }) => { + assert.notSameValue(value, arr, 'value is a new array'); + assert(Array.isArray(value), 'value is an Array exotic object'); + assert.sameValue(value.length, 3) + assert.sameValue(value[0], 'a'); + assert.sameValue(value[1], 'b'); + assert.sameValue(value[2], 'c'); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/yield-spread-obj.js b/js/src/tests/test262/language/expressions/async-generator/yield-spread-obj.js new file mode 100644 index 0000000000..d397a95d38 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/yield-spread-obj.js @@ -0,0 +1,52 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-spread-obj.case +// - src/async-generators/default/async-expression.template +/*--- +description: Use yield value in a object spread position (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [object-spread, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + Spread Properties + + PropertyDefinition[Yield]: + (...) + ...AssignmentExpression[In, ?Yield] + +---*/ + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield { + ...yield, + y: 1, + ...yield yield, + }; +}; + +var iter = gen(); + +iter.next(); +iter.next({ x: 42 }); +iter.next({ x: 'lol' }); +var item = iter.next({ y: 39 }); + +item.then(({ done, value }) => { + assert.sameValue(value.x, 42); + assert.sameValue(value.y, 39); + assert.sameValue(Object.keys(value).length, 2); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/yield-star-async-next.js b/js/src/tests/test262/language/expressions/async-generator/yield-star-async-next.js new file mode 100644 index 0000000000..320a642ab0 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/yield-star-async-next.js @@ -0,0 +1,219 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-async-next.case +// - src/async-generators/default/async-expression.template +/*--- +description: Execution order for yield* with async iterator and next() (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, async-iteration, Symbol.asyncIterator] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + +---*/ +var log = []; +var obj = { + get [Symbol.iterator]() { + log.push({ name: "get [Symbol.iterator]" }); + }, + get [Symbol.asyncIterator]() { + log.push({ + name: "get [Symbol.asyncIterator]", + thisValue: this + }); + return function() { + log.push({ + name: "call [Symbol.asyncIterator]", + thisValue: this, + args: [...arguments] + }); + var nextCount = 0; + return { + name: "asyncIterator", + get next() { + log.push({ + name: "get next", + thisValue: this + }); + return function() { + log.push({ + name: "call next", + thisValue: this, + args: [...arguments] + }); + + nextCount++; + if (nextCount == 1) { + return { + name: "next-promise-1", + get then() { + log.push({ + name: "get next then (1)", + thisValue: this + }); + return function(resolve) { + log.push({ + name: "call next then (1)", + thisValue: this, + args: [...arguments] + }); + + resolve({ + name: "next-result-1", + get value() { + log.push({ + name: "get next value (1)", + thisValue: this + }); + return "next-value-1"; + }, + get done() { + log.push({ + name: "get next done (1)", + thisValue: this + }); + return false; + } + }); + }; + } + }; + } + + return { + name: "next-promise-2", + get then() { + log.push({ + name: "get next then (2)", + thisValue: this + }); + return function(resolve) { + log.push({ + name: "call next then (2)", + thisValue: this, + args: [...arguments] + }); + + resolve({ + name: "next-result-2", + get value() { + log.push({ + name: "get next value (2)", + thisValue: this + }); + return "next-value-2"; + }, + get done() { + log.push({ + name: "get next done (2)", + thisValue: this + }); + return true; + } + }); + }; + } + }; + }; + } + }; + }; + } +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + log.push({ name: "before yield*" }); + var v = yield* obj; + log.push({ + name: "after yield*", + value: v + }); + return "return-value"; + +}; + +var iter = gen(); + +assert.sameValue(log.length, 0, "log.length"); + +iter.next("next-arg-1").then(v => { + assert.sameValue(log[0].name, "before yield*"); + + assert.sameValue(log[1].name, "get [Symbol.asyncIterator]"); + assert.sameValue(log[1].thisValue, obj, "get [Symbol.asyncIterator] thisValue"); + + assert.sameValue(log[2].name, "call [Symbol.asyncIterator]"); + assert.sameValue(log[2].thisValue, obj, "[Symbol.asyncIterator] thisValue"); + assert.sameValue(log[2].args.length, 0, "[Symbol.asyncIterator] args.length"); + + assert.sameValue(log[3].name, "get next"); + assert.sameValue(log[3].thisValue.name, "asyncIterator", "get next thisValue"); + + assert.sameValue(log[4].name, "call next"); + assert.sameValue(log[4].thisValue.name, "asyncIterator", "next thisValue"); + assert.sameValue(log[4].args.length, 1, "next args.length"); + assert.sameValue(log[4].args[0], undefined, "next args[0]"); + + assert.sameValue(log[5].name, "get next then (1)"); + assert.sameValue(log[5].thisValue.name, "next-promise-1", "get next then thisValue"); + + assert.sameValue(log[6].name, "call next then (1)"); + assert.sameValue(log[6].thisValue.name, "next-promise-1", "next then thisValue"); + assert.sameValue(log[6].args.length, 2, "next then args.length"); + assert.sameValue(typeof log[6].args[0], "function", "next then args[0]"); + assert.sameValue(typeof log[6].args[1], "function", "next then args[1]"); + + assert.sameValue(log[7].name, "get next done (1)"); + assert.sameValue(log[7].thisValue.name, "next-result-1", "get next done thisValue"); + + assert.sameValue(log[8].name, "get next value (1)"); + assert.sameValue(log[8].thisValue.name, "next-result-1", "get next value thisValue"); + + assert.sameValue(v.value, "next-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 9, "log.length"); + + iter.next("next-arg-2").then(v => { + assert.sameValue(log[9].name, "call next"); + assert.sameValue(log[9].thisValue.name, "asyncIterator", "next thisValue"); + assert.sameValue(log[9].args.length, 1, "next args.length"); + assert.sameValue(log[9].args[0], "next-arg-2", "next args[0]"); + + assert.sameValue(log[10].name, "get next then (2)"); + assert.sameValue(log[10].thisValue.name, "next-promise-2", "get next then thisValue"); + + assert.sameValue(log[11].name, "call next then (2)"); + assert.sameValue(log[11].thisValue.name, "next-promise-2", "next then thisValue"); + assert.sameValue(log[11].args.length, 2, "next then args.length"); + assert.sameValue(typeof log[11].args[0], "function", "next then args[0]"); + assert.sameValue(typeof log[11].args[1], "function", "next then args[1]"); + + assert.sameValue(log[12].name, "get next done (2)"); + assert.sameValue(log[12].thisValue.name, "next-result-2", "get next done thisValue"); + + assert.sameValue(log[13].name, "get next value (2)"); + assert.sameValue(log[13].thisValue.name, "next-result-2", "get next value thisValue"); + + assert.sameValue(log[14].name, "after yield*"); + assert.sameValue(log[14].value, "next-value-2"); + + assert.sameValue(v.value, "return-value"); + assert.sameValue(v.done, true); + + assert.sameValue(log.length, 15, "log.length"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/yield-star-async-return.js b/js/src/tests/test262/language/expressions/async-generator/yield-star-async-return.js new file mode 100644 index 0000000000..f3ffe4fc85 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/yield-star-async-return.js @@ -0,0 +1,235 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-async-return.case +// - src/async-generators/default/async-expression.template +/*--- +description: execution order for yield* with async iterator and return() (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [async-iteration, Symbol.asyncIterator] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + ... + 6. Repeat + ... + c. Else, + i. Assert: received.[[Type]] is return. + ii. Let return be ? GetMethod(iterator, "return"). + iii. If return is undefined, return Completion(received). + iv. Let innerReturnResult be ? Call(return, iterator, « received.[[Value]] »). + v. If generatorKind is async, then set innerReturnResult to ? Await(innerReturnResult). + ... + vii. Let done be ? IteratorComplete(innerReturnResult). + viii. If done is true, then + 1. Let value be ? IteratorValue(innerReturnResult). + 2. If generatorKind is async, then set value to ? Await(value). + 3. Return Completion{[[Type]]: return, [[Value]]: value, [[Target]]: empty}. + ix. If generatorKind is async, then let received be AsyncGeneratorYield(? IteratorValue(innerResult)). + ... + + AsyncGeneratorYield ( value ) + ... + 8. Return ! AsyncGeneratorResolve(generator, value, false). + ... + +---*/ +var log = []; +var obj = { + [Symbol.asyncIterator]() { + var returnCount = 0; + return { + name: 'asyncIterator', + get next() { + log.push({ name: "get next" }); + return function() { + return { + value: "next-value-1", + done: false + }; + }; + }, + get return() { + log.push({ + name: "get return", + thisValue: this + }); + return function() { + log.push({ + name: "call return", + thisValue: this, + args: [...arguments] + }); + + returnCount++; + if (returnCount == 1) { + return { + name: "return-promise-1", + get then() { + log.push({ + name: "get return then (1)", + thisValue: this + }); + return function(resolve) { + log.push({ + name: "call return then (1)", + thisValue: this, + args: [...arguments] + }); + + resolve({ + name: "return-result-1", + get value() { + log.push({ + name: "get return value (1)", + thisValue: this + }); + return "return-value-1"; + }, + get done() { + log.push({ + name: "get return done (1)", + thisValue: this + }); + return false; + } + }); + }; + } + }; + } + + return { + name: "return-promise-2", + get then() { + log.push({ + name: "get return then (2)", + thisValue: this + }); + return function(resolve) { + log.push({ + name: "call return then (2)", + thisValue: this, + args: [...arguments] + }); + + resolve({ + name: "return-result-2", + get value() { + log.push({ + name: "get return value (2)", + thisValue: this + }); + return "return-value-2"; + }, + get done() { + log.push({ + name: "get return done (2)", + thisValue: this + }); + return true; + } + }); + }; + } + }; + }; + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + log.push({ name: "before yield*" }); + yield* obj; + +}; + +var iter = gen(); + +assert.sameValue(log.length, 0, "log.length"); + +iter.next().then(v => { + assert.sameValue(log[0].name, "before yield*"); + + assert.sameValue(log[1].name, "get next"); + + assert.sameValue(v.value, "next-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 2, "log.length"); + + iter.return("return-arg-1").then(v => { + assert.sameValue(log[2].name, "get return"); + assert.sameValue(log[2].thisValue.name, "asyncIterator", "get return thisValue"); + + assert.sameValue(log[3].name, "call return"); + assert.sameValue(log[3].thisValue.name, "asyncIterator", "return thisValue"); + assert.sameValue(log[3].args.length, 1, "return args.length"); + assert.sameValue(log[3].args[0], "return-arg-1", "return args[0]"); + + assert.sameValue(log[4].name, "get return then (1)"); + assert.sameValue(log[4].thisValue.name, "return-promise-1", "get return then thisValue"); + + assert.sameValue(log[5].name, "call return then (1)"); + assert.sameValue(log[5].thisValue.name, "return-promise-1", "return then thisValue"); + assert.sameValue(log[5].args.length, 2, "return then args.length"); + assert.sameValue(typeof log[5].args[0], "function", "return then args[0]"); + assert.sameValue(typeof log[5].args[1], "function", "return then args[1]"); + + assert.sameValue(log[6].name, "get return done (1)"); + assert.sameValue(log[6].thisValue.name, "return-result-1", "get return done thisValue"); + + assert.sameValue(log[7].name, "get return value (1)"); + assert.sameValue(log[7].thisValue.name, "return-result-1", "get return value thisValue"); + + assert.sameValue(v.value, "return-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 8, "log.length"); + + iter.return("return-arg-2").then(v => { + assert.sameValue(log[8].name, "get return"); + assert.sameValue(log[8].thisValue.name, "asyncIterator", "get return thisValue"); + + assert.sameValue(log[9].name, "call return"); + assert.sameValue(log[9].thisValue.name, "asyncIterator", "return thisValue"); + assert.sameValue(log[9].args.length, 1, "return args.length"); + assert.sameValue(log[9].args[0], "return-arg-2", "return args[0]"); + + assert.sameValue(log[10].name, "get return then (2)"); + assert.sameValue(log[10].thisValue.name, "return-promise-2", "get return then thisValue"); + + assert.sameValue(log[11].name, "call return then (2)"); + assert.sameValue(log[11].thisValue.name, "return-promise-2", "return then thisValue"); + assert.sameValue(log[11].args.length, 2, "return then args.length"); + assert.sameValue(typeof log[11].args[0], "function", "return then args[0]"); + assert.sameValue(typeof log[11].args[1], "function", "return then args[1]"); + + assert.sameValue(log[12].name, "get return done (2)"); + assert.sameValue(log[12].thisValue.name, "return-result-2", "get return done thisValue"); + + assert.sameValue(log[13].name, "get return value (2)"); + assert.sameValue(log[13].thisValue.name, "return-result-2", "get return value thisValue"); + + assert.sameValue(v.value, "return-value-2"); + assert.sameValue(v.done, true); + + assert.sameValue(log.length, 14, "log.length"); + }).then($DONE, $DONE); + }).catch($DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/yield-star-async-throw.js b/js/src/tests/test262/language/expressions/async-generator/yield-star-async-throw.js new file mode 100644 index 0000000000..aa6321eec2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/yield-star-async-throw.js @@ -0,0 +1,243 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-async-throw.case +// - src/async-generators/default/async-expression.template +/*--- +description: execution order for yield* with async iterator and throw() (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [async-iteration, Symbol.asyncIterator] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + ... + 6. Repeat + ... + b. Else if received.[[Type]] is throw, then + i. Let throw be ? GetMethod(iterator, "throw"). + ii. If throw is not undefined, then + 1. Let innerResult be ? Call(throw, iterator, « received.[[Value]] »). + 2. If generatorKind is async, then set innerResult to ? Await(innerResult). + ... + 5. Let done be ? IteratorComplete(innerResult). + 6. If done is true, then + a. Let resultValue be Return ? IteratorValue(innerResult). + b. If generatorKind is async, then set resultValue to ? Await(resultValue). + c. Return resultValue. + 7. If generatorKind is async, then let received be AsyncGeneratorYield(? IteratorValue(innerResult)). + ... + + AsyncGeneratorYield ( value ) + + ... + 8. Return ! AsyncGeneratorResolve(generator, value, false). + ... + +---*/ +var log = []; +var obj = { + [Symbol.asyncIterator]() { + var throwCount = 0; + return { + name: "asyncIterator", + get next() { + log.push({ name: "get next" }); + return function() { + return { + value: "next-value-1", + done: false + }; + }; + }, + get throw() { + log.push({ + name: "get throw", + thisValue: this + }); + return function() { + log.push({ + name: "call throw", + thisValue: this, + args: [...arguments] + }); + + throwCount++; + if (throwCount == 1) { + return { + name: "throw-promise-1", + get then() { + log.push({ + name: "get throw then (1)", + thisValue: this + }); + return function(resolve) { + log.push({ + name: "call throw then (1)", + thisValue: this, + args: [...arguments] + }); + + resolve({ + name: "throw-result-1", + get value() { + log.push({ + name: "get throw value (1)", + thisValue: this + }); + return "throw-value-1"; + }, + get done() { + log.push({ + name: "get throw done (1)", + thisValue: this + }); + return false; + } + }); + }; + } + }; + } + + return { + name: "throw-promise-2", + get then() { + log.push({ + name: "get throw then (2)", + thisValue: this + }); + return function(resolve) { + log.push({ + name: "call throw then (2)", + thisValue: this, + args: [...arguments] + }); + + resolve({ + name: "throw-result-2", + get value() { + log.push({ + name: "get throw value (2)", + thisValue: this + }); + return "throw-value-2"; + }, + get done() { + log.push({ + name: "get throw done (2)", + thisValue: this + }); + return true; + } + }); + }; + } + }; + }; + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + log.push({ name: "before yield*" }); + var v = yield* obj; + log.push({ + name: "after yield*", + value: v + }); + return "return-value"; + +}; + +var iter = gen(); + +assert.sameValue(log.length, 0, "log.length"); + +iter.next().then(v => { + assert.sameValue(log[0].name, "before yield*"); + + assert.sameValue(log[1].name, "get next"); + + assert.sameValue(v.value, "next-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 2, "log.length"); + + iter.throw("throw-arg-1").then(v => { + assert.sameValue(log[2].name, "get throw"); + assert.sameValue(log[2].thisValue.name, "asyncIterator", "get throw thisValue"); + + assert.sameValue(log[3].name, "call throw"); + assert.sameValue(log[3].thisValue.name, "asyncIterator", "throw thisValue"); + assert.sameValue(log[3].args.length, 1, "throw args.length"); + assert.sameValue(log[3].args[0], "throw-arg-1", "throw args[0]"); + + assert.sameValue(log[4].name, "get throw then (1)"); + assert.sameValue(log[4].thisValue.name, "throw-promise-1", "get throw thisValue"); + + assert.sameValue(log[5].name, "call throw then (1)"); + assert.sameValue(log[5].thisValue.name, "throw-promise-1", "throw thisValue"); + assert.sameValue(log[5].args.length, 2, "throw then args.length"); + assert.sameValue(typeof log[5].args[0], "function", "throw then args[0]"); + assert.sameValue(typeof log[5].args[1], "function", "throw then args[1]"); + + assert.sameValue(log[6].name, "get throw done (1)"); + assert.sameValue(log[6].thisValue.name, "throw-result-1", "get throw done thisValue"); + + assert.sameValue(log[7].name, "get throw value (1)"); + assert.sameValue(log[7].thisValue.name, "throw-result-1", "get throw value thisValue"); + + assert.sameValue(v.value, "throw-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 8, "log.length"); + + iter.throw("throw-arg-2").then(v => { + assert.sameValue(log[8].name, "get throw"); + assert.sameValue(log[8].thisValue.name, "asyncIterator", "get throw thisValue"); + + assert.sameValue(log[9].name, "call throw"); + assert.sameValue(log[9].thisValue.name, "asyncIterator", "throw thisValue"); + assert.sameValue(log[9].args.length, 1, "throw args.length"); + assert.sameValue(log[9].args[0], "throw-arg-2", "throw args[0]"); + + assert.sameValue(log[10].name, "get throw then (2)"); + assert.sameValue(log[10].thisValue.name, "throw-promise-2", "get throw thisValue"); + + assert.sameValue(log[11].name, "call throw then (2)"); + assert.sameValue(log[11].thisValue.name, "throw-promise-2", "throw thisValue"); + assert.sameValue(log[11].args.length, 2, "throw then args.length"); + assert.sameValue(typeof log[11].args[0], "function", "throw then args[0]"); + assert.sameValue(typeof log[11].args[1], "function", "throw then args[1]"); + + assert.sameValue(log[12].name, "get throw done (2)"); + assert.sameValue(log[12].thisValue.name, "throw-result-2", "get throw done thisValue"); + + assert.sameValue(log[13].name, "get throw value (2)"); + assert.sameValue(log[13].thisValue.name, "throw-result-2", "get throw value thisValue"); + + assert.sameValue(log[14].name, "after yield*"); + assert.sameValue(log[14].value, "throw-value-2"); + + assert.sameValue(v.value, "return-value"); + assert.sameValue(v.done, true); + + assert.sameValue(log.length, 15, "log.length"); + }).then($DONE, $DONE); + }).catch($DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/yield-star-expr-abrupt.js b/js/src/tests/test262/language/expressions/async-generator/yield-star-expr-abrupt.js new file mode 100644 index 0000000000..a0ea9df5f0 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/yield-star-expr-abrupt.js @@ -0,0 +1,54 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-expr-abrupt.case +// - src/async-generators/default/async-expression.template +/*--- +description: Abrupt completion while getting yield* operand (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + ... + +---*/ +var obj = {}; +var abrupt = function() { + throw obj; +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* abrupt(); + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, obj, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-async-get-abrupt.js b/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-async-get-abrupt.js new file mode 100644 index 0000000000..680e212d9b --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-async-get-abrupt.js @@ -0,0 +1,74 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-get-abrupt.case +// - src/async-generators/default/async-expression.template +/*--- +description: Abrupt completion while getting [Symbol.asyncIterator] (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + get [Symbol.asyncIterator]() { + throw reason; + } +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-async-not-callable-boolean-throw.js b/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-async-not-callable-boolean-throw.js new file mode 100644 index 0000000000..91b1890579 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-async-not-callable-boolean-throw.js @@ -0,0 +1,73 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-not-callable-boolean-throw.case +// - src/async-generators/default/async-expression.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.asyncIterator] (boolean) (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + 3. If func is either undefined or null, return undefined. + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]: false +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-async-not-callable-number-throw.js b/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-async-not-callable-number-throw.js new file mode 100644 index 0000000000..c9085eccde --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-async-not-callable-number-throw.js @@ -0,0 +1,73 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-not-callable-number-throw.case +// - src/async-generators/default/async-expression.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.asyncIterator] (number) (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + 3. If func is either undefined or null, return undefined. + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]: 0 +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-async-not-callable-object-throw.js b/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-async-not-callable-object-throw.js new file mode 100644 index 0000000000..87b20d1267 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-async-not-callable-object-throw.js @@ -0,0 +1,73 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-not-callable-object-throw.case +// - src/async-generators/default/async-expression.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.asyncIterator] (object) (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + 3. If func is either undefined or null, return undefined. + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]: {} +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-async-not-callable-string-throw.js b/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-async-not-callable-string-throw.js new file mode 100644 index 0000000000..8cea57851b --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-async-not-callable-string-throw.js @@ -0,0 +1,73 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-not-callable-string-throw.case +// - src/async-generators/default/async-expression.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.asyncIterator] (string) (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + 3. If func is either undefined or null, return undefined. + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]: '' +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-async-not-callable-symbol-throw.js b/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-async-not-callable-symbol-throw.js new file mode 100644 index 0000000000..90088427c3 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-async-not-callable-symbol-throw.js @@ -0,0 +1,73 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-not-callable-symbol-throw.case +// - src/async-generators/default/async-expression.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.asyncIterator] (symbol) (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + 3. If func is either undefined or null, return undefined. + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]: Symbol.asyncIterator +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-async-null-sync-get-abrupt.js b/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-async-null-sync-get-abrupt.js new file mode 100644 index 0000000000..9815973073 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-async-null-sync-get-abrupt.js @@ -0,0 +1,79 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-null-sync-get-abrupt.case +// - src/async-generators/default/async-expression.template +/*--- +description: Abrupt completion while getting @@iterator after null @@asyncIterator (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + +---*/ +var calls = 0; +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw reason; + }, + get [Symbol.asyncIterator]() { + calls += 1; + return null; + } +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, 'reject reason'); + assert.sameValue(calls, 1); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-async-return-method-is-null.js b/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-async-return-method-is-null.js new file mode 100644 index 0000000000..3442f40923 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-async-return-method-is-null.js @@ -0,0 +1,56 @@ +// |reftest| async +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-generator-function-definitions-runtime-semantics-evaluation +description: > + If iterator's "return" method is `null`, + received completion is forwarded to the runtime. +info: | + YieldExpression : yield * AssignmentExpression + + [...] + 7. Repeat, + [...] + c. Else, + i. Assert: received.[[Type]] is return. + ii. Let return be ? GetMethod(iterator, "return"). + iii. If return is undefined, then + [...] + 2. Return Completion(received). + + GetMethod ( V, P ) + + [...] + 2. Let func be ? GetV(V, P). + 3. If func is either undefined or null, return undefined. +features: [Symbol.asyncIterator, async-iteration] +flags: [async] +---*/ + +var returnGets = 0; +var asyncIterable = { + [Symbol.asyncIterator]: function() { + return this; + }, + next: function() { + return {value: 1, done: false}; + }, + get return() { + returnGets += 1; + return null; + }, +}; + +async function* asyncGenerator() { + yield* asyncIterable; +} + +var asyncIterator = asyncGenerator(); +asyncIterator.next().then(function() { + return asyncIterator.return(2).then(function(result) { + assert.sameValue(result.value, 2); + assert.sameValue(result.done, true); + assert.sameValue(returnGets, 1); + }); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-async-returns-abrupt.js b/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-async-returns-abrupt.js new file mode 100644 index 0000000000..3375e618d8 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-async-returns-abrupt.js @@ -0,0 +1,70 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-returns-abrupt.case +// - src/async-generators/default/async-expression.template +/*--- +description: Abrupt completion while calling [Symbol.asyncIterator] (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + 6. Let iterator be ? Call(method, obj). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + throw reason; + } +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-async-returns-boolean-throw.js b/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-async-returns-boolean-throw.js new file mode 100644 index 0000000000..e56a3da991 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-async-returns-boolean-throw.js @@ -0,0 +1,70 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-returns-boolean-throw.case +// - src/async-generators/default/async-expression.template +/*--- +description: Non object returned by [Symbol.asyncIterator]() - boolean (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + 6. Let iterator be ? Call(method, obj). + 7. If Type(iterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return true; + } +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-async-returns-null-throw.js b/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-async-returns-null-throw.js new file mode 100644 index 0000000000..45a5ee2896 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-async-returns-null-throw.js @@ -0,0 +1,70 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-returns-null-throw.case +// - src/async-generators/default/async-expression.template +/*--- +description: Non object returned by [Symbol.asyncIterator]() - null (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + 6. Let iterator be ? Call(method, obj). + 7. If Type(iterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return null; + } +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-async-returns-number-throw.js b/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-async-returns-number-throw.js new file mode 100644 index 0000000000..51ce6dc606 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-async-returns-number-throw.js @@ -0,0 +1,70 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-returns-number-throw.case +// - src/async-generators/default/async-expression.template +/*--- +description: Non object returned by [Symbol.asyncIterator]() - number (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + 6. Let iterator be ? Call(method, obj). + 7. If Type(iterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return 42; + } +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-async-returns-string-throw.js b/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-async-returns-string-throw.js new file mode 100644 index 0000000000..14930e0820 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-async-returns-string-throw.js @@ -0,0 +1,70 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-returns-string-throw.case +// - src/async-generators/default/async-expression.template +/*--- +description: Non object returned by [Symbol.asyncIterator]() - string (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + 6. Let iterator be ? Call(method, obj). + 7. If Type(iterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return '42'; + } +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-async-returns-symbol-throw.js b/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-async-returns-symbol-throw.js new file mode 100644 index 0000000000..3c507a4c0c --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-async-returns-symbol-throw.js @@ -0,0 +1,70 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-returns-symbol-throw.case +// - src/async-generators/default/async-expression.template +/*--- +description: Non object returned by [Symbol.asyncIterator]() - symbol (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + 6. Let iterator be ? Call(method, obj). + 7. If Type(iterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return Symbol.asyncIterator; + } +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-async-returns-undefined-throw.js b/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-async-returns-undefined-throw.js new file mode 100644 index 0000000000..9172c549ba --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-async-returns-undefined-throw.js @@ -0,0 +1,70 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-returns-undefined-throw.case +// - src/async-generators/default/async-expression.template +/*--- +description: Non object returned by [Symbol.asyncIterator]() - undefined (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + 6. Let iterator be ? Call(method, obj). + 7. If Type(iterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return undefined; + } +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-async-throw-method-is-null.js b/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-async-throw-method-is-null.js new file mode 100644 index 0000000000..d913b05c5d --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-async-throw-method-is-null.js @@ -0,0 +1,73 @@ +// |reftest| async +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-generator-function-definitions-runtime-semantics-evaluation +description: > + If iterator's "throw" method is `null`, + AsyncIteratorClose is called before rising TypeError. +info: | + YieldExpression : yield * AssignmentExpression + + [...] + 7. Repeat, + [...] + b. Else if received.[[Type]] is throw, then + i. Let throw be ? GetMethod(iterator, "throw"). + ii. If throw is not undefined, then + [...] + iii. Else, + [...] + 3. If generatorKind is async, perform ? AsyncIteratorClose(iteratorRecord, closeCompletion). + [...] + 6. Throw a TypeError exception. + + GetMethod ( V, P ) + + [...] + 2. Let func be ? GetV(V, P). + 3. If func is either undefined or null, return undefined. + + AsyncIteratorClose ( iteratorRecord, completion ) + + [...] + 4. Let innerResult be GetMethod(iterator, "return"). + 5. If innerResult.[[Type]] is normal, then + a. Let return be innerResult.[[Value]]. + b. If return is undefined, return Completion(completion). +features: [Symbol.asyncIterator, async-iteration] +flags: [async] +---*/ + +var throwGets = 0; +var returnGets = 0; +var asyncIterable = { + [Symbol.asyncIterator]: function() { + return this; + }, + next: function() { + return {value: 1, done: false}; + }, + get throw() { + throwGets += 1; + return null; + }, + get return() { + returnGets += 1; + }, +}; + +async function* asyncGenerator() { + yield* asyncIterable; +} + +var asyncIterator = asyncGenerator(); +asyncIterator.next().then(function() { + return asyncIterator.throw(); +}).then(function(result) { + throw new Test262Error("Promise should be rejected, got: " + result.value); +}, function(err) { + assert.sameValue(err.constructor, TypeError); + assert.sameValue(throwGets, 1); + assert.sameValue(returnGets, 1); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-async-undefined-sync-get-abrupt.js b/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-async-undefined-sync-get-abrupt.js new file mode 100644 index 0000000000..b23681d778 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-async-undefined-sync-get-abrupt.js @@ -0,0 +1,79 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-undefined-sync-get-abrupt.case +// - src/async-generators/default/async-expression.template +/*--- +description: Abrupt completion while getting @@iterator after undefined @@asyncIterator (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + +---*/ +var calls = 0; +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw reason; + }, + get [Symbol.asyncIterator]() { + calls += 1; + return undefined; + } +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, 'reject reason'); + assert.sameValue(calls, 1); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-sync-get-abrupt.js b/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-sync-get-abrupt.js new file mode 100644 index 0000000000..654bfb3e2f --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-sync-get-abrupt.js @@ -0,0 +1,73 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-get-abrupt.case +// - src/async-generators/default/async-expression.template +/*--- +description: Abrupt completion while getting [Symbol.iterator] (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw reason; + } +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-sync-not-callable-boolean-throw.js b/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-sync-not-callable-boolean-throw.js new file mode 100644 index 0000000000..d14d4869c8 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-sync-not-callable-boolean-throw.js @@ -0,0 +1,72 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-not-callable-boolean-throw.case +// - src/async-generators/default/async-expression.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.iterator] (boolean) (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]: false +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-sync-not-callable-number-throw.js b/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-sync-not-callable-number-throw.js new file mode 100644 index 0000000000..094a4f23e5 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-sync-not-callable-number-throw.js @@ -0,0 +1,72 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-not-callable-number-throw.case +// - src/async-generators/default/async-expression.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.iterator] (number) (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]: 0 +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-sync-not-callable-object-throw.js b/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-sync-not-callable-object-throw.js new file mode 100644 index 0000000000..6bff6abde4 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-sync-not-callable-object-throw.js @@ -0,0 +1,72 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-not-callable-object-throw.case +// - src/async-generators/default/async-expression.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.iterator] (object) (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]: {} +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-sync-not-callable-string-throw.js b/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-sync-not-callable-string-throw.js new file mode 100644 index 0000000000..bbf7743722 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-sync-not-callable-string-throw.js @@ -0,0 +1,72 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-not-callable-string-throw.case +// - src/async-generators/default/async-expression.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.iterator] (string) (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]: '' +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-sync-not-callable-symbol-throw.js b/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-sync-not-callable-symbol-throw.js new file mode 100644 index 0000000000..dd005edf1f --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-sync-not-callable-symbol-throw.js @@ -0,0 +1,72 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-not-callable-symbol-throw.case +// - src/async-generators/default/async-expression.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.iterator] (symbol) (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]: Symbol.iterator +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-sync-returns-abrupt.js b/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-sync-returns-abrupt.js new file mode 100644 index 0000000000..6dbd5d7c24 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-sync-returns-abrupt.js @@ -0,0 +1,67 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-returns-abrupt.case +// - src/async-generators/default/async-expression.template +/*--- +description: Abrupt completion while calling [Symbol.iterator] (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + ... + +---*/ +var reason = {}; +var obj = { + [Symbol.iterator]() { + throw reason; + } +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-sync-returns-boolean-throw.js b/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-sync-returns-boolean-throw.js new file mode 100644 index 0000000000..488e1c77e8 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-sync-returns-boolean-throw.js @@ -0,0 +1,72 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-returns-boolean-throw.case +// - src/async-generators/default/async-expression.template +/*--- +description: Non object returned by [Symbol.iterator]() - boolean (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + iii. Return ? CreateAsyncFromSyncIterator(syncIterator). + ... + + CreateAsyncFromSyncIterator(syncIterator) + + 1. If Type(syncIterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]() { + return true; + } +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-sync-returns-null-throw.js b/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-sync-returns-null-throw.js new file mode 100644 index 0000000000..1d4d0bdfc9 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-sync-returns-null-throw.js @@ -0,0 +1,72 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-returns-null-throw.case +// - src/async-generators/default/async-expression.template +/*--- +description: Non object returned by [Symbol.iterator]() - null (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + iii. Return ? CreateAsyncFromSyncIterator(syncIterator). + ... + + CreateAsyncFromSyncIterator(syncIterator) + + 1. If Type(syncIterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]() { + return null; + } +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-sync-returns-number-throw.js b/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-sync-returns-number-throw.js new file mode 100644 index 0000000000..67753254d5 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-sync-returns-number-throw.js @@ -0,0 +1,72 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-returns-number-throw.case +// - src/async-generators/default/async-expression.template +/*--- +description: Non object returned by [Symbol.iterator]() - number (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + iii. Return ? CreateAsyncFromSyncIterator(syncIterator). + ... + + CreateAsyncFromSyncIterator(syncIterator) + + 1. If Type(syncIterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]() { + return 0; + } +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-sync-returns-string-throw.js b/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-sync-returns-string-throw.js new file mode 100644 index 0000000000..184d6ecc6d --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-sync-returns-string-throw.js @@ -0,0 +1,72 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-returns-string-throw.case +// - src/async-generators/default/async-expression.template +/*--- +description: Non object returned by [Symbol.iterator]() - string (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + iii. Return ? CreateAsyncFromSyncIterator(syncIterator). + ... + + CreateAsyncFromSyncIterator(syncIterator) + + 1. If Type(syncIterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]() { + return ''; + } +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-sync-returns-symbol-throw.js b/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-sync-returns-symbol-throw.js new file mode 100644 index 0000000000..eaee7c8cf4 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-sync-returns-symbol-throw.js @@ -0,0 +1,72 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-returns-symbol-throw.case +// - src/async-generators/default/async-expression.template +/*--- +description: Non object returned by [Symbol.iterator]() - symbol (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + iii. Return ? CreateAsyncFromSyncIterator(syncIterator). + ... + + CreateAsyncFromSyncIterator(syncIterator) + + 1. If Type(syncIterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]() { + return Symbol.iterator; + } +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-sync-returns-undefined-throw.js b/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-sync-returns-undefined-throw.js new file mode 100644 index 0000000000..21e957e81c --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/yield-star-getiter-sync-returns-undefined-throw.js @@ -0,0 +1,72 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-returns-undefined-throw.case +// - src/async-generators/default/async-expression.template +/*--- +description: Non object returned by [Symbol.iterator]() - undefined (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + iii. Return ? CreateAsyncFromSyncIterator(syncIterator). + ... + + CreateAsyncFromSyncIterator(syncIterator) + + 1. If Type(syncIterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]() { + return undefined; + } +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/yield-star-next-call-done-get-abrupt.js b/js/src/tests/test262/language/expressions/async-generator/yield-star-next-call-done-get-abrupt.js new file mode 100644 index 0000000000..f622c3c399 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/yield-star-next-call-done-get-abrupt.js @@ -0,0 +1,73 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-call-done-get-abrupt.case +// - src/async-generators/default/async-expression.template +/*--- +description: Abrupt completion while getting done (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + v. Let done be ? IteratorComplete(innerResult). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + get done() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/yield-star-next-call-returns-abrupt.js b/js/src/tests/test262/language/expressions/async-generator/yield-star-next-call-returns-abrupt.js new file mode 100644 index 0000000000..252379d854 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/yield-star-next-call-returns-abrupt.js @@ -0,0 +1,65 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-call-returns-abrupt.case +// - src/async-generators/default/async-expression.template +/*--- +description: Abrupt completion while calling next (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + throw reason; + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/yield-star-next-call-value-get-abrupt.js b/js/src/tests/test262/language/expressions/async-generator/yield-star-next-call-value-get-abrupt.js new file mode 100644 index 0000000000..99ac29bdac --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/yield-star-next-call-value-get-abrupt.js @@ -0,0 +1,75 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-call-value-get-abrupt.case +// - src/async-generators/default/async-expression.template +/*--- +description: Abrupt completion while getting value (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + vi. If done is true, then + 1. Return ? IteratorValue(innerResult). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + done: true, + get value() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/yield-star-next-get-abrupt.js b/js/src/tests/test262/language/expressions/async-generator/yield-star-next-get-abrupt.js new file mode 100644 index 0000000000..5d9a7c5f45 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/yield-star-next-get-abrupt.js @@ -0,0 +1,65 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-get-abrupt.case +// - src/async-generators/default/async-expression.template +/*--- +description: Abrupt completion while getting next (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + get next() { + throw reason; + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/yield-star-next-non-object-ignores-then.js b/js/src/tests/test262/language/expressions/async-generator/yield-star-next-non-object-ignores-then.js new file mode 100644 index 0000000000..63eef6716e --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/yield-star-next-non-object-ignores-then.js @@ -0,0 +1,85 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-non-object-ignores-then.case +// - src/async-generators/default/async-expression.template +/*--- +description: If next() value is not-object, do not access respective then property (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + +---*/ +Number.prototype.then = function() { + throw new Test262Error('Number#then should not be used'); +}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return 42; + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, 'TypeError'); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/yield-star-next-not-callable-boolean-throw.js b/js/src/tests/test262/language/expressions/async-generator/yield-star-next-not-callable-boolean-throw.js new file mode 100644 index 0000000000..20193e3f47 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/yield-star-next-not-callable-boolean-throw.js @@ -0,0 +1,62 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-boolean-throw.case +// - src/async-generators/default/async-expression.template +/*--- +description: Not-callable next value in a yield star position - boolean (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: true + }; + } +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/yield-star-next-not-callable-null-throw.js b/js/src/tests/test262/language/expressions/async-generator/yield-star-next-not-callable-null-throw.js new file mode 100644 index 0000000000..8bf77f19a8 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/yield-star-next-not-callable-null-throw.js @@ -0,0 +1,62 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-null-throw.case +// - src/async-generators/default/async-expression.template +/*--- +description: Not-callable next value in a yield star position - null (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: null + }; + } +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/yield-star-next-not-callable-number-throw.js b/js/src/tests/test262/language/expressions/async-generator/yield-star-next-not-callable-number-throw.js new file mode 100644 index 0000000000..9d9301be19 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/yield-star-next-not-callable-number-throw.js @@ -0,0 +1,62 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-number-throw.case +// - src/async-generators/default/async-expression.template +/*--- +description: Not-callable next value in a yield star position - number (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: 42 + }; + } +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/yield-star-next-not-callable-object-throw.js b/js/src/tests/test262/language/expressions/async-generator/yield-star-next-not-callable-object-throw.js new file mode 100644 index 0000000000..cc1572642f --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/yield-star-next-not-callable-object-throw.js @@ -0,0 +1,62 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-object-throw.case +// - src/async-generators/default/async-expression.template +/*--- +description: Not-callable next value in a yield star position - object (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: {} + }; + } +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/yield-star-next-not-callable-string-throw.js b/js/src/tests/test262/language/expressions/async-generator/yield-star-next-not-callable-string-throw.js new file mode 100644 index 0000000000..e22a643088 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/yield-star-next-not-callable-string-throw.js @@ -0,0 +1,62 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-string-throw.case +// - src/async-generators/default/async-expression.template +/*--- +description: Not-callable next value in a yield star position - string (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: '' + }; + } +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/yield-star-next-not-callable-symbol-throw.js b/js/src/tests/test262/language/expressions/async-generator/yield-star-next-not-callable-symbol-throw.js new file mode 100644 index 0000000000..4818e841ea --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/yield-star-next-not-callable-symbol-throw.js @@ -0,0 +1,62 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-symbol-throw.case +// - src/async-generators/default/async-expression.template +/*--- +description: Not-callable next value in a yield star position - symbol (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: Symbol('oi') + }; + } +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/yield-star-next-not-callable-undefined-throw.js b/js/src/tests/test262/language/expressions/async-generator/yield-star-next-not-callable-undefined-throw.js new file mode 100644 index 0000000000..012882909b --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/yield-star-next-not-callable-undefined-throw.js @@ -0,0 +1,62 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-undefined-throw.case +// - src/async-generators/default/async-expression.template +/*--- +description: Not-callable next value in a yield star position - undefined (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: undefined + }; + } +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/yield-star-next-then-get-abrupt.js b/js/src/tests/test262/language/expressions/async-generator/yield-star-next-then-get-abrupt.js new file mode 100644 index 0000000000..9b17fc3c26 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/yield-star-next-then-get-abrupt.js @@ -0,0 +1,89 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-get-abrupt.case +// - src/async-generators/default/async-expression.template +/*--- +description: Return abrupt after getting next().then (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 8. Let then be Get(resolution, "then"). + ... + 10. Get thenAction be then.[[Value]]. + ... + 12. Perform EnqueueJob("PromiseJobs", PromiseResolveThenableJob, « promise, + resolution, thenAction »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + get then() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, 'reject reason'); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/yield-star-next-then-non-callable-boolean-fulfillpromise.js b/js/src/tests/test262/language/expressions/async-generator/yield-star-next-then-non-callable-boolean-fulfillpromise.js new file mode 100644 index 0000000000..d9ff3991a4 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/yield-star-next-then-non-callable-boolean-fulfillpromise.js @@ -0,0 +1,83 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-boolean-fulfillpromise.case +// - src/async-generators/default/async-expression.template +/*--- +description: FulfillPromise if next().then is not-callable (boolean) (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: true, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/yield-star-next-then-non-callable-null-fulfillpromise.js b/js/src/tests/test262/language/expressions/async-generator/yield-star-next-then-non-callable-null-fulfillpromise.js new file mode 100644 index 0000000000..d74800050b --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/yield-star-next-then-non-callable-null-fulfillpromise.js @@ -0,0 +1,83 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-null-fulfillpromise.case +// - src/async-generators/default/async-expression.template +/*--- +description: FulfillPromise if next().then is not-callable (null) (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: null, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/yield-star-next-then-non-callable-number-fulfillpromise.js b/js/src/tests/test262/language/expressions/async-generator/yield-star-next-then-non-callable-number-fulfillpromise.js new file mode 100644 index 0000000000..25b5c37d4a --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/yield-star-next-then-non-callable-number-fulfillpromise.js @@ -0,0 +1,83 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-number-fulfillpromise.case +// - src/async-generators/default/async-expression.template +/*--- +description: FulfillPromise if next().then is not-callable (number) (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: 39, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/yield-star-next-then-non-callable-object-fulfillpromise.js b/js/src/tests/test262/language/expressions/async-generator/yield-star-next-then-non-callable-object-fulfillpromise.js new file mode 100644 index 0000000000..d6357f39bc --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/yield-star-next-then-non-callable-object-fulfillpromise.js @@ -0,0 +1,83 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-object-fulfillpromise.case +// - src/async-generators/default/async-expression.template +/*--- +description: FulfillPromise if next().then is not-callable (object) (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: {}, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/yield-star-next-then-non-callable-string-fulfillpromise.js b/js/src/tests/test262/language/expressions/async-generator/yield-star-next-then-non-callable-string-fulfillpromise.js new file mode 100644 index 0000000000..91eb7c35a0 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/yield-star-next-then-non-callable-string-fulfillpromise.js @@ -0,0 +1,83 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-string-fulfillpromise.case +// - src/async-generators/default/async-expression.template +/*--- +description: FulfillPromise if next().then is not-callable (string) (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: '', + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/yield-star-next-then-non-callable-symbol-fulfillpromise.js b/js/src/tests/test262/language/expressions/async-generator/yield-star-next-then-non-callable-symbol-fulfillpromise.js new file mode 100644 index 0000000000..e1377fab5a --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/yield-star-next-then-non-callable-symbol-fulfillpromise.js @@ -0,0 +1,83 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-symbol-fulfillpromise.case +// - src/async-generators/default/async-expression.template +/*--- +description: FulfillPromise if next().then is not-callable (symbol) (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: Symbol('oi'), + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/yield-star-next-then-non-callable-undefined-fulfillpromise.js b/js/src/tests/test262/language/expressions/async-generator/yield-star-next-then-non-callable-undefined-fulfillpromise.js new file mode 100644 index 0000000000..6513d7bbce --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/yield-star-next-then-non-callable-undefined-fulfillpromise.js @@ -0,0 +1,83 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-undefined-fulfillpromise.case +// - src/async-generators/default/async-expression.template +/*--- +description: FulfillPromise if next().then is not-callable (undefined) (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: undefined, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/yield-star-next-then-returns-abrupt.js b/js/src/tests/test262/language/expressions/async-generator/yield-star-next-then-returns-abrupt.js new file mode 100644 index 0000000000..dc842b3e16 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/yield-star-next-then-returns-abrupt.js @@ -0,0 +1,89 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-returns-abrupt.case +// - src/async-generators/default/async-expression.template +/*--- +description: Return abrupt after calling next().then (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 8. Let then be Get(resolution, "then"). + ... + 10. Get thenAction be then.[[Value]]. + ... + 12. Perform EnqueueJob("PromiseJobs", PromiseResolveThenableJob, « promise, + resolution, thenAction »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, 'reject reason'); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/yield-star-sync-next.js b/js/src/tests/test262/language/expressions/async-generator/yield-star-sync-next.js new file mode 100644 index 0000000000..226e16aed7 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/yield-star-sync-next.js @@ -0,0 +1,222 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-sync-next.case +// - src/async-generators/default/async-expression.template +/*--- +description: execution order for yield* with sync iterator and next() (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, async-iteration, Symbol.asyncIterator] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + ... + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + 5. Let received be NormalCompletion(undefined). + 6. Repeat + a. If received.[[Type]] is normal, then + i. Let innerResult be ? IteratorNext(iterator, received.[[Value]]). + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + v. Let done be ? IteratorComplete(innerResult). + vi. If done is true, then + 1. Return ? IteratorValue(innerResult). + vii. Let received be GeneratorYield(innerResult). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + iii. Return ? CreateAsyncFromSyncIterator(syncIterator). + ... + + %AsyncFromSyncIteratorPrototype%.next ( value ) + + ... + 5. Let nextResult be IteratorNext(syncIterator, value). + ... + 7. Let nextValue be IteratorValue(nextResult). + ... + 9. Let nextDone be IteratorComplete(nextResult). + ... + 12. Perform ! Call(valueWrapperCapability.[[Resolve]], undefined, + « nextValue »). + ... + 14. Set onFulfilled.[[Done]] to nextDone. + 15. Perform ! PerformPromiseThen(valueWrapperCapability.[[Promise]], + onFulfilled, undefined, promiseCapability). + ... + + Async Iterator Value Unwrap Functions + + 1. Return ! CreateIterResultObject(value, F.[[Done]]). + +---*/ +var log = []; +var obj = { + get [Symbol.iterator]() { + log.push({ + name: "get [Symbol.iterator]", + thisValue: this + }); + return function() { + log.push({ + name: "call [Symbol.iterator]", + thisValue: this, + args: [...arguments] + }); + var nextCount = 0; + return { + name: "syncIterator", + get next() { + log.push({ + name: "get next", + thisValue: this + }); + return function() { + log.push({ + name: "call next", + thisValue: this, + args: [...arguments] + }); + + nextCount++; + if (nextCount == 1) { + return { + name: "next-result-1", + get value() { + log.push({ + name: "get next value (1)", + thisValue: this + }); + return "next-value-1"; + }, + get done() { + log.push({ + name: "get next done (1)", + thisValue: this + }); + return false; + } + }; + } + + return { + name: "next-result-2", + get value() { + log.push({ + name: "get next value (2)", + thisValue: this + }); + return "next-value-2"; + }, + get done() { + log.push({ + name: "get next done (2)", + thisValue: this + }); + return true; + } + }; + }; + } + }; + }; + }, + get [Symbol.asyncIterator]() { + log.push({ name: "get [Symbol.asyncIterator]" }); + return null; + } +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + log.push({ name: "before yield*" }); + var v = yield* obj; + log.push({ + name: "after yield*", + value: v + }); + return "return-value"; + +}; + +var iter = gen(); + +assert.sameValue(log.length, 0, "log.length"); + +iter.next("next-arg-1").then(v => { + assert.sameValue(log[0].name, "before yield*"); + + assert.sameValue(log[1].name, "get [Symbol.asyncIterator]"); + + assert.sameValue(log[2].name, "get [Symbol.iterator]"); + assert.sameValue(log[2].thisValue, obj, "get [Symbol.iterator] thisValue"); + + assert.sameValue(log[3].name, "call [Symbol.iterator]"); + assert.sameValue(log[3].thisValue, obj, "[Symbol.iterator] thisValue"); + assert.sameValue(log[3].args.length, 0, "[Symbol.iterator] args.length"); + + assert.sameValue(log[4].name, "get next"); + assert.sameValue(log[4].thisValue.name, "syncIterator", "get next thisValue"); + + assert.sameValue(log[5].name, "call next"); + assert.sameValue(log[5].thisValue.name, "syncIterator", "next thisValue"); + assert.sameValue(log[5].args.length, 1, "next args.length"); + assert.sameValue(log[5].args[0], undefined, "next args[0]"); + + assert.sameValue(log[6].name, "get next done (1)"); + assert.sameValue(log[6].thisValue.name, "next-result-1", "get next done thisValue"); + + assert.sameValue(log[7].name, "get next value (1)"); + assert.sameValue(log[7].thisValue.name, "next-result-1", "get next value thisValue"); + + assert.sameValue(v.value, "next-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 8, "log.length"); + + iter.next("next-arg-2").then(v => { + assert.sameValue(log[8].name, "call next"); + assert.sameValue(log[8].thisValue.name, "syncIterator", "next thisValue"); + assert.sameValue(log[8].args.length, 1, "next args.length"); + assert.sameValue(log[8].args[0], "next-arg-2", "next args[0]"); + + assert.sameValue(log[9].name, "get next done (2)"); + assert.sameValue(log[9].thisValue.name, "next-result-2", "get next done thisValue"); + + assert.sameValue(log[10].name, "get next value (2)"); + assert.sameValue(log[10].thisValue.name, "next-result-2", "get next value thisValue"); + + assert.sameValue(log[11].name, "after yield*"); + assert.sameValue(log[11].value, "next-value-2"); + + assert.sameValue(v.value, "return-value"); + assert.sameValue(v.done, true); + + assert.sameValue(log.length, 12, "log.length"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/yield-star-sync-return.js b/js/src/tests/test262/language/expressions/async-generator/yield-star-sync-return.js new file mode 100644 index 0000000000..d516923f24 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/yield-star-sync-return.js @@ -0,0 +1,197 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-sync-return.case +// - src/async-generators/default/async-expression.template +/*--- +description: execution order for yield* with sync iterator and return() (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, async-iteration, Symbol.asyncIterator] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + ... + 6. Repeat + ... + c. Else, + i. Assert: received.[[Type]] is return. + ii. Let return be ? GetMethod(iterator, "return"). + iii. If return is undefined, return Completion(received). + iv. Let innerReturnResult be ? Call(return, iterator, + « received.[[Value]] »). + v. If generatorKind is async, then set innerReturnResult to + ? Await(innerReturnResult). + ... + vii. Let done be ? IteratorComplete(innerReturnResult). + viii. If done is true, then + 1. Let value be ? IteratorValue(innerReturnResult). + 2. Return Completion{[[Type]]: return, [[Value]]: value, + [[Target]]: empty}. + ix. Let received be GeneratorYield(innerResult). + + %AsyncFromSyncIteratorPrototype%.return ( value ) + + 5. Let return be GetMethod(syncIterator, "return"). + ... + ... + 8. Let returnResult be Call(return, syncIterator, « value »). + ... + 11. Let returnValue be IteratorValue(returnResult). + .. + 13. Let returnDone be IteratorComplete(returnResult). + ... + 16. Perform ! Call(valueWrapperCapability.[[Resolve]], undefined, « returnValue »). + ... + 18. Set onFulfilled.[[Done]] to returnDone. + 19. Perform ! PerformPromiseThen(valueWrapperCapability.[[Promise]], + onFulfilled, undefined, promiseCapability). + ... + +---*/ +var log = []; +var obj = { + [Symbol.iterator]() { + var returnCount = 0; + return { + name: "syncIterator", + get next() { + log.push({ name: "get next" }); + return function() { + return { + value: "next-value-1", + done: false + }; + }; + }, + get return() { + log.push({ + name: "get return", + thisValue: this + }); + return function() { + log.push({ + name: "call return", + thisValue: this, + args: [...arguments] + }); + + returnCount++; + if (returnCount == 1) { + return { + name: "return-result-1", + get value() { + log.push({ + name: "get return value (1)", + thisValue: this + }); + return "return-value-1"; + }, + get done() { + log.push({ + name: "get return done (1)", + thisValue: this + }); + return false; + } + }; + } + + return { + name: "return-result-2", + get value() { + log.push({ + name: "get return value (2)", + thisValue: this + }); + return "return-value-2"; + }, + get done() { + log.push({ + name: "get return done (2)", + thisValue: this + }); + return true; + } + }; + }; + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + log.push({ name: "before yield*" }); + yield* obj; + +}; + +var iter = gen(); + +assert.sameValue(log.length, 0, "log.length"); + +iter.next().then(v => { + assert.sameValue(log[0].name, "before yield*"); + + assert.sameValue(log[1].name, "get next"); + + assert.sameValue(v.value, "next-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 2, "log.length"); + + iter.return("return-arg-1").then(v => { + assert.sameValue(log[2].name, "get return"); + assert.sameValue(log[2].thisValue.name, "syncIterator", "get return thisValue"); + + assert.sameValue(log[3].name, "call return"); + assert.sameValue(log[3].thisValue.name, "syncIterator", "return thisValue"); + assert.sameValue(log[3].args.length, 1, "return args.length"); + assert.sameValue(log[3].args[0], "return-arg-1", "return args[0]"); + + assert.sameValue(log[4].name, "get return done (1)"); + assert.sameValue(log[4].thisValue.name, "return-result-1", "get return done thisValue"); + + assert.sameValue(log[5].name, "get return value (1)"); + assert.sameValue(log[5].thisValue.name, "return-result-1", "get return value thisValue"); + + assert.sameValue(v.value, "return-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 6, "log.length"); + + iter.return().then(v => { + assert.sameValue(log[6].name, "get return"); + assert.sameValue(log[6].thisValue.name, "syncIterator", "get return thisValue"); + + assert.sameValue(log[7].name, "call return"); + assert.sameValue(log[7].thisValue.name, "syncIterator", "get return thisValue"); + assert.sameValue(log[7].args.length, 1, "return args.length"); + assert.sameValue(log[7].args[0], undefined, "return args[0]"); + + assert.sameValue(log[8].name, "get return done (2)"); + assert.sameValue(log[8].thisValue.name, "return-result-2", "get return done thisValue"); + + assert.sameValue(log[9].name, "get return value (2)"); + assert.sameValue(log[9].thisValue.name, "return-result-2", "get return value thisValue"); + + assert.sameValue(v.value, "return-value-2"); + assert.sameValue(v.done, true); + + assert.sameValue(log.length, 10, "log.length"); + }).then($DONE, $DONE); + }).catch($DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/yield-star-sync-throw.js b/js/src/tests/test262/language/expressions/async-generator/yield-star-sync-throw.js new file mode 100644 index 0000000000..b84a1ebd79 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/yield-star-sync-throw.js @@ -0,0 +1,203 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-sync-throw.case +// - src/async-generators/default/async-expression.template +/*--- +description: execution order for yield* with sync iterator and throw() (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + ... + 6. Repeat + ... + b. Else if received.[[Type]] is throw, then + i. Let throw be ? GetMethod(iterator, "throw"). + ii. If throw is not undefined, then + 1. Let innerResult be ? Call(throw, iterator, « received.[[Value]] »). + 2. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + 5. Let done be ? IteratorComplete(innerResult). + 6. If done is true, then + a. Return ? IteratorValue(innerResult). + 7. Let received be GeneratorYield(innerResult). + ... + + %AsyncFromSyncIteratorPrototype%.throw ( value ) + + ... + 5. Let throw be GetMethod(syncIterator, "throw"). + ... + 8. Let throwResult be Call(throw, syncIterator, « value »). + ... + 11. Let throwValue be IteratorValue(throwResult). + ... + 13. Let throwDone be IteratorComplete(throwResult). + ... + 16. Perform ! Call(valueWrapperCapability.[[Resolve]], undefined, + « throwValue »). + ... + 18. Set onFulfilled.[[Done]] to throwDone. + 19. Perform ! PerformPromiseThen(valueWrapperCapability.[[Promise]], + onFulfilled, undefined, promiseCapability). + ... + +---*/ +var log = []; +var obj = { + [Symbol.iterator]() { + var throwCount = 0; + return { + name: "syncIterator", + get next() { + log.push({ name: "get next" }); + return function() { + return { + value: "next-value-1", + done: false + }; + }; + }, + get throw() { + log.push({ + name: "get throw", + thisValue: this + }); + return function() { + log.push({ + name: "call throw", + thisValue: this, + args: [...arguments] + }); + + throwCount++; + if (throwCount == 1) { + return { + name: "throw-result-1", + get value() { + log.push({ + name: "get throw value (1)", + thisValue: this + }); + return "throw-value-1"; + }, + get done() { + log.push({ + name: "get throw done (1)", + thisValue: this + }); + return false; + } + }; + } + + return { + name: "throw-result-2", + get value() { + log.push({ + name: "get throw value (2)", + thisValue: this + }); + return "throw-value-2"; + }, + get done() { + log.push({ + name: "get throw done (2)", + thisValue: this + }); + return true; + } + }; + }; + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + log.push({ name: "before yield*" }); + var v = yield* obj; + log.push({ + name: "after yield*", + value: v + }); + return "return-value"; + +}; + +var iter = gen(); + +assert.sameValue(log.length, 0, "log.length"); + +iter.next().then(v => { + assert.sameValue(log[0].name, "before yield*"); + + assert.sameValue(log[1].name, "get next"); + + assert.sameValue(v.value, "next-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 2, "log.length"); + + iter.throw("throw-arg-1").then(v => { + assert.sameValue(log[2].name, "get throw"); + assert.sameValue(log[2].thisValue.name, "syncIterator", "get throw thisValue"); + + assert.sameValue(log[3].name, "call throw"); + assert.sameValue(log[3].thisValue.name, "syncIterator", "throw thisValue"); + assert.sameValue(log[3].args.length, 1, "throw args.length"); + assert.sameValue(log[3].args[0], "throw-arg-1", "throw args[0]"); + + assert.sameValue(log[4].name, "get throw done (1)"); + assert.sameValue(log[4].thisValue.name, "throw-result-1", "get throw done thisValue"); + + assert.sameValue(log[5].name, "get throw value (1)"); + assert.sameValue(log[5].thisValue.name, "throw-result-1", "get throw value thisValue"); + + assert.sameValue(v.value, "throw-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 6, "log.length"); + + iter.throw().then(v => { + assert.sameValue(log[6].name, "get throw"); + assert.sameValue(log[6].thisValue.name, "syncIterator", "get throw thisValue"); + + assert.sameValue(log[7].name, "call throw"); + assert.sameValue(log[7].thisValue.name, "syncIterator", "throw thisValue"); + assert.sameValue(log[7].args.length, 1, "throw args.length"); + assert.sameValue(log[7].args[0], undefined, "throw args[0]"); + + assert.sameValue(log[8].name, "get throw done (2)"); + assert.sameValue(log[8].thisValue.name, "throw-result-2", "get throw done thisValue"); + + assert.sameValue(log[9].name, "get throw value (2)"); + assert.sameValue(log[9].thisValue.name, "throw-result-2", "get throw value thisValue"); + + assert.sameValue(log[10].name, "after yield*"); + assert.sameValue(log[10].value, "throw-value-2"); + + assert.sameValue(v.value, "return-value"); + assert.sameValue(v.done, true); + + assert.sameValue(log.length, 11, "log.length"); + }).then($DONE, $DONE); + }).catch($DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/async-generator/yield-thenable-create-resolving-functions-reject.js b/js/src/tests/test262/language/expressions/async-generator/yield-thenable-create-resolving-functions-reject.js new file mode 100644 index 0000000000..1acb66a6f3 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/yield-thenable-create-resolving-functions-reject.js @@ -0,0 +1,75 @@ +// |reftest| async +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-generator-function-definitions-runtime-semantics-evaluation +description: > + `reject` is anonymous built-in function with length of 1. +info: | + YieldExpression : yield AssignmentExpression + + [...] + 4. If generatorKind is async, then return ? AsyncGeneratorYield(value). + + AsyncGeneratorYield ( value ) + + [...] + 5. Set value to ? Await(value). + [...] + 9. Return ! AsyncGeneratorResolve(generator, value, false). + + Await + + [...] + 2. Let promise be ? PromiseResolve(%Promise%, value). + [...] + + PromiseResolve ( C, x ) + + [...] + 3. Let promiseCapability be ? NewPromiseCapability(C). + 4. Perform ? Call(promiseCapability.[[Resolve]], undefined, « x »). + 5. Return promiseCapability.[[Promise]]. + + NewPromiseCapability ( C ) + + [...] + 7. Let promise be ? Construct(C, « executor »). + [...] + 11. Return promiseCapability. + + Promise ( executor ) + + [...] + 8. Let resolvingFunctions be CreateResolvingFunctions(promise). + [...] + 11. Return promise. + + CreateResolvingFunctions ( promise ) + + [...] + 7. Let reject be ! CreateBuiltinFunction(stepsReject, « [[Promise]], [[AlreadyResolved]] »). + [...] + 10. Return the Record { [[Resolve]]: resolve, [[Reject]]: reject }. +flags: [async] +features: [async-iteration, Reflect.construct] +includes: [isConstructor.js] +---*/ + +var thenable = { + then: function(resolve, reject) { + resolve(reject); + }, +}; + +var iter = (async function*() { + yield thenable; +}()); + +iter.next().then(function(result) { + var reject = result.value; + assert(!isConstructor(reject)); + assert.sameValue(reject.length, 1); + assert.sameValue(reject.name, ''); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/async-generator/yield-thenable-create-resolving-functions-resolve.js b/js/src/tests/test262/language/expressions/async-generator/yield-thenable-create-resolving-functions-resolve.js new file mode 100644 index 0000000000..543b17c9f9 --- /dev/null +++ b/js/src/tests/test262/language/expressions/async-generator/yield-thenable-create-resolving-functions-resolve.js @@ -0,0 +1,75 @@ +// |reftest| async +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-generator-function-definitions-runtime-semantics-evaluation +description: > + `resolve` is anonymous built-in function with length of 1. +info: | + YieldExpression : yield AssignmentExpression + + [...] + 4. If generatorKind is async, then return ? AsyncGeneratorYield(value). + + AsyncGeneratorYield ( value ) + + [...] + 5. Set value to ? Await(value). + [...] + 9. Return ! AsyncGeneratorResolve(generator, value, false). + + Await + + [...] + 2. Let promise be ? PromiseResolve(%Promise%, value). + [...] + + PromiseResolve ( C, x ) + + [...] + 3. Let promiseCapability be ? NewPromiseCapability(C). + 4. Perform ? Call(promiseCapability.[[Resolve]], undefined, « x »). + 5. Return promiseCapability.[[Promise]]. + + NewPromiseCapability ( C ) + + [...] + 7. Let promise be ? Construct(C, « executor »). + [...] + 11. Return promiseCapability. + + Promise ( executor ) + + [...] + 8. Let resolvingFunctions be CreateResolvingFunctions(promise). + [...] + 11. Return promise. + + CreateResolvingFunctions ( promise ) + + [...] + 3. Let resolve be ! CreateBuiltinFunction(stepsResolve, « [[Promise]], [[AlreadyResolved]] »). + [...] + 10. Return the Record { [[Resolve]]: resolve, [[Reject]]: reject }. +flags: [async] +features: [async-iteration, Reflect.construct] +includes: [isConstructor.js] +---*/ + +var thenable = { + then: function(resolve) { + resolve(resolve); + }, +}; + +var iter = (async function*() { + yield thenable; +}()); + +iter.next().then(function(result) { + var resolve = result.value; + assert(!isConstructor(resolve)); + assert.sameValue(resolve.length, 1); + assert.sameValue(resolve.name, ''); +}).then($DONE, $DONE); |