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/statements/class/async-gen-method-static | |
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/statements/class/async-gen-method-static')
107 files changed, 7918 insertions, 0 deletions
diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/array-destructuring-param-strict-body.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/array-destructuring-param-strict-body.js new file mode 100644 index 0000000000..949ef653e7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/array-destructuring-param-strict-body.js @@ -0,0 +1,138 @@ +// |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/cls-decl-async-gen-meth-static.template +/*--- +description: ArrayBindingPattern and Use Strict Directive are not allowed to coexist for the same function. (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [rest-parameters, async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + 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(); + + +class C { + static async *method([element]) { + "use strict"; + } +} diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/await-as-binding-identifier-escaped.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/await-as-binding-identifier-escaped.js new file mode 100644 index 0000000000..c1aa9803dc --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/await-as-binding-identifier-escaped.js @@ -0,0 +1,37 @@ +// |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-class-decl-static-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + BindingIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +$DONOTEVALUATE(); + + +class C { static async *gen() { + var \u0061wait; +}} diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/await-as-binding-identifier.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/await-as-binding-identifier.js new file mode 100644 index 0000000000..d7f1e1cfba --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/await-as-binding-identifier.js @@ -0,0 +1,37 @@ +// |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-class-decl-static-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + BindingIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +$DONOTEVALUATE(); + + +class C { static async *gen() { + var await; +}} diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/await-as-identifier-reference-escaped.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/await-as-identifier-reference-escaped.js new file mode 100644 index 0000000000..808d003b1d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/await-as-identifier-reference-escaped.js @@ -0,0 +1,37 @@ +// |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-class-decl-static-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + IdentifierReference : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +$DONOTEVALUATE(); + + +class C { static async *gen() { + void \u0061wait; +}} diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/await-as-identifier-reference.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/await-as-identifier-reference.js new file mode 100644 index 0000000000..0a231fb8ee --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/await-as-identifier-reference.js @@ -0,0 +1,37 @@ +// |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-class-decl-static-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + IdentifierReference : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +$DONOTEVALUATE(); + + +class C { static async *gen() { + void await; +}} diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/await-as-label-identifier-escaped.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/await-as-label-identifier-escaped.js new file mode 100644 index 0000000000..3cc2db647d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/await-as-label-identifier-escaped.js @@ -0,0 +1,37 @@ +// |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-class-decl-static-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a label identifier. (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + LabelIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +$DONOTEVALUATE(); + + +class C { static async *gen() { + \u0061wait: ; +}} diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/await-as-label-identifier.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/await-as-label-identifier.js new file mode 100644 index 0000000000..c511ce78db --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/await-as-label-identifier.js @@ -0,0 +1,37 @@ +// |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-class-decl-static-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a label identifier. (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + LabelIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +$DONOTEVALUATE(); + + +class C { static async *gen() { + await: ; +}} diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/browser.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/browser.js diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/dflt-params-abrupt.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/dflt-params-abrupt.js new file mode 100644 index 0000000000..81e14dc50e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/dflt-params-abrupt.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-abrupt.case +// - src/function-forms/error/cls-decl-async-gen-meth-static.template +/*--- +description: Abrupt completion returned by evaluation of initializer (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [default-parameters, async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + 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; +class C { + static async *method(_ = (function() { throw new Test262Error(); }())) { + + callCount = callCount + 1; + } +} + +assert.throws(Test262Error, function() { + C.method(); +}); + +assert.sameValue(callCount, 0, 'method body not evaluated'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/dflt-params-arg-val-not-undefined.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/dflt-params-arg-val-not-undefined.js new file mode 100644 index 0000000000..49010f9797 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/dflt-params-arg-val-not-undefined.js @@ -0,0 +1,92 @@ +// |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/cls-decl-async-gen-meth-static.template +/*--- +description: Use of initializer when argument value is not `undefined` (static class declaration async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [default-parameters, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + 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; +class C { + static async *method(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; + } +} + +// Stores a reference `ref` for case evaluation +var ref = C.method; + +ref(false, '', NaN, 0, null, obj).next().then(() => { + assert.sameValue(callCount, 1, 'method 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/statements/class/async-gen-method-static/dflt-params-arg-val-undefined.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/dflt-params-arg-val-undefined.js new file mode 100644 index 0000000000..608b9cb883 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/dflt-params-arg-val-undefined.js @@ -0,0 +1,75 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-arg-val-undefined.case +// - src/function-forms/default/cls-decl-async-gen-meth-static.template +/*--- +description: Use of initializer when argument value is `undefined` (static class declaration async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [default-parameters, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + 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; +class C { + static async *method(fromLiteral = 23, fromExpr = 45, fromHole = 99) { + assert.sameValue(fromLiteral, 23); + assert.sameValue(fromExpr, 45); + assert.sameValue(fromHole, 99); + callCount = callCount + 1; + } +} + +// Stores a reference `ref` for case evaluation +var ref = C.method; + +ref(undefined, void 0).next().then(() => { + assert.sameValue(callCount, 1, 'method invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/dflt-params-duplicates.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/dflt-params-duplicates.js new file mode 100644 index 0000000000..9b7901cd65 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/dflt-params-duplicates.js @@ -0,0 +1,67 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-duplicates.case +// - src/function-forms/syntax/cls-decl-async-gen-meth-static.template +/*--- +description: It is a Syntax Error if BoundNames of FormalParameters contains any duplicate elements. (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [default-parameters, async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + 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(); + + +class C { + static async *method(x = 0, x) { + + } +} diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/dflt-params-ref-later.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/dflt-params-ref-later.js new file mode 100644 index 0000000000..30fc7fa7c1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/dflt-params-ref-later.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-ref-later.case +// - src/function-forms/error/cls-decl-async-gen-meth-static.template +/*--- +description: Referencing a parameter that occurs later in the ParameterList (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [default-parameters, async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + 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; +class C { + static async *method(x = y, y) { + + callCount = callCount + 1; + } +} + +assert.throws(ReferenceError, function() { + C.method(); +}); + +assert.sameValue(callCount, 0, 'method body not evaluated'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/dflt-params-ref-prior.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/dflt-params-ref-prior.js new file mode 100644 index 0000000000..daf60509b5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/dflt-params-ref-prior.js @@ -0,0 +1,72 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-ref-prior.case +// - src/function-forms/default/cls-decl-async-gen-meth-static.template +/*--- +description: Referencing a parameter that occurs earlier in the ParameterList (static class declaration async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [default-parameters, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + 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; +class C { + static async *method(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; + } +} + +// Stores a reference `ref` for case evaluation +var ref = C.method; + +ref(3).next().then(() => { + assert.sameValue(callCount, 1, 'method invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/dflt-params-ref-self.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/dflt-params-ref-self.js new file mode 100644 index 0000000000..9f2bc4dfdb --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/dflt-params-ref-self.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-ref-self.case +// - src/function-forms/error/cls-decl-async-gen-meth-static.template +/*--- +description: Referencing a parameter from within its own initializer (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [default-parameters, async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + 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; +class C { + static async *method(x = x) { + + callCount = callCount + 1; + } +} + +assert.throws(ReferenceError, function() { + C.method(); +}); + +assert.sameValue(callCount, 0, 'method body not evaluated'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/dflt-params-rest.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/dflt-params-rest.js new file mode 100644 index 0000000000..5e6b021d1c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/dflt-params-rest.js @@ -0,0 +1,71 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-rest.case +// - src/function-forms/syntax/cls-decl-async-gen-meth-static.template +/*--- +description: RestParameter does not support an initializer (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [default-parameters, async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + 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(); + + +class C { + static async *method(...x = []) { + + } +} diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/dflt-params-trailing-comma.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/dflt-params-trailing-comma.js new file mode 100644 index 0000000000..16ae5a99e9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/dflt-params-trailing-comma.js @@ -0,0 +1,67 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-trailing-comma.case +// - src/function-forms/default/cls-decl-async-gen-meth-static.template +/*--- +description: A trailing comma should not increase the respective length, using default parameters (static class declaration async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + Trailing comma in the parameters list + + 14.1 Function Definitions + + FormalParameters[Yield, Await] : FormalParameterList[?Yield, ?Await] , +---*/ + + +var callCount = 0; +class C { + static async *method(a, b = 39,) { + assert.sameValue(a, 42); + assert.sameValue(b, 39); + callCount = callCount + 1; + } +} + +// Stores a reference `ref` for case evaluation +var ref = C.method; + +ref(42, undefined, 1).next().then(() => { + assert.sameValue(callCount, 1, 'method invoked exactly once'); +}).then($DONE, $DONE); + +assert.sameValue(ref.length, 1, 'length is properly set'); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/forbidden-ext/b1/browser.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/forbidden-ext/b1/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/forbidden-ext/b1/browser.js diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/forbidden-ext/b1/cls-decl-async-gen-meth-static-forbidden-ext-direct-access-prop-arguments.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/forbidden-ext/b1/cls-decl-async-gen-meth-static-forbidden-ext-direct-access-prop-arguments.js new file mode 100644 index 0000000000..ccf94751ad --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/forbidden-ext/b1/cls-decl-async-gen-meth-static-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/cls-decl-async-gen-meth-static.template +/*--- +description: Forbidden extension, f.arguments (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [arrow-function, async-functions, async-iteration, class] +flags: [generated, noStrict, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + + 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; +class C { + static async *method() { + assert.sameValue(this.method.hasOwnProperty("arguments"), false); + callCount++; + } +} + +C.method().next() + .then(() => { + assert.sameValue(callCount, 1, 'function body evaluated'); + }, $DONE).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/forbidden-ext/b1/cls-decl-async-gen-meth-static-forbidden-ext-direct-access-prop-caller.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/forbidden-ext/b1/cls-decl-async-gen-meth-static-forbidden-ext-direct-access-prop-caller.js new file mode 100644 index 0000000000..8e4893e5cc --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/forbidden-ext/b1/cls-decl-async-gen-meth-static-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/cls-decl-async-gen-meth-static.template +/*--- +description: Forbidden extension, o.caller (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [arrow-function, async-functions, async-iteration, class] +flags: [generated, noStrict, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + + 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; +class C { + static async *method() { + assert.sameValue(this.method.hasOwnProperty("caller"), false); + callCount++; + } +} + +C.method().next() + .then(() => { + assert.sameValue(callCount, 1, 'function body evaluated'); + }, $DONE).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/forbidden-ext/b1/shell.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/forbidden-ext/b1/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/forbidden-ext/b1/shell.js diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/forbidden-ext/b2/browser.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/forbidden-ext/b2/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/forbidden-ext/b2/browser.js diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/forbidden-ext/b2/cls-decl-async-gen-meth-static-forbidden-ext-indirect-access-own-prop-caller-get.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/forbidden-ext/b2/cls-decl-async-gen-meth-static-forbidden-ext-indirect-access-own-prop-caller-get.js new file mode 100644 index 0000000000..4071306341 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/forbidden-ext/b2/cls-decl-async-gen-meth-static-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/cls-decl-async-gen-meth-static.template +/*--- +description: Forbidden extension, o.caller (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [arrow-function, async-functions, async-iteration, class] +flags: [generated, noStrict, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + + 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; +class C { + static async *method() { + /* implicit 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 + 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, this.method); + } + callCount++; + } +} + +C.method().next() + .then(() => { + assert.sameValue(callCount, 1, 'function body evaluated'); + }, $DONE).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/forbidden-ext/b2/cls-decl-async-gen-meth-static-forbidden-ext-indirect-access-own-prop-caller-value.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/forbidden-ext/b2/cls-decl-async-gen-meth-static-forbidden-ext-indirect-access-own-prop-caller-value.js new file mode 100644 index 0000000000..7c47646f0c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/forbidden-ext/b2/cls-decl-async-gen-meth-static-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/cls-decl-async-gen-meth-static.template +/*--- +description: Forbidden extension, o.caller (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [arrow-function, async-functions, async-iteration, class] +flags: [generated, noStrict, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + + 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; +class C { + static async *method() { + /* implicit 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 + 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, this.method); + } + callCount++; + } +} + +C.method().next() + .then(() => { + assert.sameValue(callCount, 1, 'function body evaluated'); + }, $DONE).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/forbidden-ext/b2/cls-decl-async-gen-meth-static-forbidden-ext-indirect-access-prop-caller.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/forbidden-ext/b2/cls-decl-async-gen-meth-static-forbidden-ext-indirect-access-prop-caller.js new file mode 100644 index 0000000000..c845f26f16 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/forbidden-ext/b2/cls-decl-async-gen-meth-static-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/cls-decl-async-gen-meth-static.template +/*--- +description: Forbidden extension, o.caller (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [arrow-function, async-functions, async-iteration, class] +flags: [generated, noStrict, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + + 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; +class C { + static async *method() { + /* implicit 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 + 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, this.method); + } + callCount++; + } +} + +C.method().next() + .then(() => { + assert.sameValue(callCount, 1, 'function body evaluated'); + }, $DONE).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/forbidden-ext/b2/shell.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/forbidden-ext/b2/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/forbidden-ext/b2/shell.js diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/forbidden-ext/browser.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/forbidden-ext/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/forbidden-ext/browser.js diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/forbidden-ext/shell.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/forbidden-ext/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/forbidden-ext/shell.js diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/object-destructuring-param-strict-body.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/object-destructuring-param-strict-body.js new file mode 100644 index 0000000000..0669b18670 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/object-destructuring-param-strict-body.js @@ -0,0 +1,138 @@ +// |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/cls-decl-async-gen-meth-static.template +/*--- +description: ObjectBindingPattern and Use Strict Directive are not allowed to coexist for the same function. (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [rest-parameters, async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + 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(); + + +class C { + static async *method({property}) { + "use strict"; + } +} diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/params-trailing-comma-multiple.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/params-trailing-comma-multiple.js new file mode 100644 index 0000000000..5ac5a17650 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/params-trailing-comma-multiple.js @@ -0,0 +1,67 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/params-trailing-comma-multiple.case +// - src/function-forms/default/cls-decl-async-gen-meth-static.template +/*--- +description: A trailing comma should not increase the respective length, using multiple parameters (static class declaration async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + Trailing comma in the parameters list + + 14.1 Function Definitions + + FormalParameters[Yield, Await] : FormalParameterList[?Yield, ?Await] , +---*/ + + +var callCount = 0; +class C { + static async *method(a, b,) { + assert.sameValue(a, 42); + assert.sameValue(b, 39); + callCount = callCount + 1; + } +} + +// Stores a reference `ref` for case evaluation +var ref = C.method; + +ref(42, 39, 1).next().then(() => { + assert.sameValue(callCount, 1, 'method invoked exactly once'); +}).then($DONE, $DONE); + +assert.sameValue(ref.length, 2, 'length is properly set'); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/params-trailing-comma-single.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/params-trailing-comma-single.js new file mode 100644 index 0000000000..ce92295b3d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/params-trailing-comma-single.js @@ -0,0 +1,66 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/params-trailing-comma-single.case +// - src/function-forms/default/cls-decl-async-gen-meth-static.template +/*--- +description: A trailing comma should not increase the respective length, using a single parameter (static class declaration async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + Trailing comma in the parameters list + + 14.1 Function Definitions + + FormalParameters[Yield, Await] : FormalParameterList[?Yield, ?Await] , +---*/ + + +var callCount = 0; +class C { + static async *method(a,) { + assert.sameValue(a, 42); + callCount = callCount + 1; + } +} + +// Stores a reference `ref` for case evaluation +var ref = C.method; + +ref(42, 39).next().then(() => { + assert.sameValue(callCount, 1, 'method invoked exactly once'); +}).then($DONE, $DONE); + +assert.sameValue(ref.length, 1, 'length is properly set'); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/rest-param-strict-body.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/rest-param-strict-body.js new file mode 100644 index 0000000000..6f77dcec53 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/rest-param-strict-body.js @@ -0,0 +1,138 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/rest-param-strict-body.case +// - src/function-forms/syntax/cls-decl-async-gen-meth-static.template +/*--- +description: RestParameter and Use Strict Directive are not allowed to coexist for the same function. (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [rest-parameters, async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + 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(); + + +class C { + static async *method(a,...rest) { + "use strict"; + } +} diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/rest-params-trailing-comma-early-error.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/rest-params-trailing-comma-early-error.js new file mode 100644 index 0000000000..cbc14b1619 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/rest-params-trailing-comma-early-error.js @@ -0,0 +1,64 @@ +// |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/cls-decl-async-gen-meth-static.template +/*--- +description: It's a syntax error if a FunctionRestParameter is followed by a trailing comma (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + 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(); + + +class C { + static async *method(...a,) { + + } +} diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/shell.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/shell.js diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-as-binding-identifier-escaped.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-as-binding-identifier-escaped.js new file mode 100644 index 0000000000..04f56c8bd7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-as-binding-identifier-escaped.js @@ -0,0 +1,37 @@ +// |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-class-decl-static-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + BindingIdentifier : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +$DONOTEVALUATE(); + + +class C { static async *gen() { + var yi\u0065ld; +}} diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-as-binding-identifier.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-as-binding-identifier.js new file mode 100644 index 0000000000..f3b028e636 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-as-binding-identifier.js @@ -0,0 +1,37 @@ +// |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-class-decl-static-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + BindingIdentifier : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +$DONOTEVALUATE(); + + +class C { static async *gen() { + var yield; +}} diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-as-identifier-reference-escaped.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-as-identifier-reference-escaped.js new file mode 100644 index 0000000000..61bb80ffeb --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-as-identifier-reference-escaped.js @@ -0,0 +1,37 @@ +// |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-class-decl-static-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + IdentifierReference : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +$DONOTEVALUATE(); + + +class C { static async *gen() { + void yi\u0065ld; +}} diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-as-identifier-reference.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-as-identifier-reference.js new file mode 100644 index 0000000000..3e6df8cc98 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-as-identifier-reference.js @@ -0,0 +1,37 @@ +// |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-class-decl-static-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + IdentifierReference : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +$DONOTEVALUATE(); + + +class C { static async *gen() { + void yield; +}} diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-as-label-identifier-escaped.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-as-label-identifier-escaped.js new file mode 100644 index 0000000000..ed8c94e6ff --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-as-label-identifier-escaped.js @@ -0,0 +1,37 @@ +// |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-class-decl-static-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as a label identifier. (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + LabelIdentifier : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +$DONOTEVALUATE(); + + +class C { static async *gen() { + yi\u0065ld: ; +}} diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-as-label-identifier.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-as-label-identifier.js new file mode 100644 index 0000000000..58f5930948 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-as-label-identifier.js @@ -0,0 +1,37 @@ +// |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-class-decl-static-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as a label identifier. (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + LabelIdentifier : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +$DONOTEVALUATE(); + + +class C { static async *gen() { + yield: ; +}} diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-identifier-spread-strict-strict.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-identifier-spread-strict-strict.js new file mode 100644 index 0000000000..de3f96587b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-identifier-spread-strict-strict.js @@ -0,0 +1,55 @@ +// |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-class-decl-static-method.template +/*--- +description: It's an early error if the AssignmentExpression is a function body with yield as an identifier in strict mode. (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [object-spread, async-iteration] +flags: [generated, onlyStrict] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + Spread Properties + + PropertyDefinition[Yield]: + (...) + ...AssignmentExpression[In, ?Yield] + +---*/ +$DONOTEVALUATE(); + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + return { + ...(function() { + var yield; + throw new Test262Error(); + }()), + } +}} + +var gen = C.gen; + +var iter = gen(); + + + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-identifier-strict-strict.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-identifier-strict-strict.js new file mode 100644 index 0000000000..7ef3a6f717 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-identifier-strict-strict.js @@ -0,0 +1,46 @@ +// |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-class-decl-static-method.template +/*--- +description: It's an early error if the generator body has another function body with yield as an identifier in strict mode. (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated, onlyStrict] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +$DONOTEVALUATE(); + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + (function() { + var yield; + throw new Test262Error(); + }()) +}} + +var gen = C.gen; + +var iter = gen(); + + + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-promise-reject-next-catch.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-promise-reject-next-catch.js new file mode 100644 index 0000000000..2c9fde7744 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-promise-reject-next-catch.js @@ -0,0 +1,51 @@ +// |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-class-decl-static-method.template +/*--- +description: yield Promise.reject(value) is treated as throw value (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield Promise.reject(error); + yield "unreachable"; +}} + +var gen = C.gen; + +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/statements/class/async-gen-method-static/yield-promise-reject-next-for-await-of-async-iterator.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-promise-reject-next-for-await-of-async-iterator.js new file mode 100644 index 0000000000..347dfc59cb --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-promise-reject-next-for-await-of-async-iterator.js @@ -0,0 +1,57 @@ +// |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-class-decl-static-method.template +/*--- +description: yield * [Promise.reject(value)] is treated as throw value (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); +async function * readFile() { + yield Promise.reject(error); + yield "unreachable"; +} + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + for await (let line of readFile()) { + yield line; + } +}} + +var gen = C.gen; + +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/statements/class/async-gen-method-static/yield-promise-reject-next-for-await-of-sync-iterator.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-promise-reject-next-for-await-of-sync-iterator.js new file mode 100644 index 0000000000..09cbb76b40 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-promise-reject-next-for-await-of-sync-iterator.js @@ -0,0 +1,56 @@ +// |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-class-decl-static-method.template +/*--- +description: yield Promise.reject(value) in for-await-of is treated as throw value (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); +let iterable = [ + Promise.reject(error), + "unreachable" +]; + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + for await (let value of iterable) { + yield value; + } +}} + +var gen = C.gen; + +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/statements/class/async-gen-method-static/yield-promise-reject-next-yield-star-async-iterator.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-promise-reject-next-yield-star-async-iterator.js new file mode 100644 index 0000000000..bd83eced36 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-promise-reject-next-yield-star-async-iterator.js @@ -0,0 +1,55 @@ +// |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-class-decl-static-method.template +/*--- +description: yield * (async iterator) is treated as throw value (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); +async function * readFile() { + yield Promise.reject(error); + yield "unreachable"; +} + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield * readFile(); + +}} + +var gen = C.gen; + +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/statements/class/async-gen-method-static/yield-promise-reject-next-yield-star-sync-iterator.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-promise-reject-next-yield-star-sync-iterator.js new file mode 100644 index 0000000000..e081278277 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-promise-reject-next-yield-star-sync-iterator.js @@ -0,0 +1,54 @@ +// |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-class-decl-static-method.template +/*--- +description: yield * (async iterator) is treated as throw value (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); +let iterable = [ + Promise.reject(error), + "unreachable" +]; + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield * iterable; +}} + +var gen = C.gen; + +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/statements/class/async-gen-method-static/yield-promise-reject-next.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-promise-reject-next.js new file mode 100644 index 0000000000..e3cd184f98 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-promise-reject-next.js @@ -0,0 +1,51 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: yield Promise.reject(value) is treated as throw value (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield Promise.reject(error); + yield "unreachable"; +}} + +var gen = C.gen; + +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/statements/class/async-gen-method-static/yield-spread-arr-multiple.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-spread-arr-multiple.js new file mode 100644 index 0000000000..a45a13e0bd --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-spread-arr-multiple.js @@ -0,0 +1,57 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-spread-arr-multiple.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: Use yield value in a array spread position (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated, async] +includes: [compareArray.js] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + Array Initializer + + SpreadElement[Yield, Await]: + ...AssignmentExpression[+In, ?Yield, ?Await] + +---*/ +var arr = ['a', 'b', 'c']; +var item; + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield [...yield yield]; +}} + +var gen = C.gen; + +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/statements/class/async-gen-method-static/yield-spread-arr-single.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-spread-arr-single.js new file mode 100644 index 0000000000..21f3704f58 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-spread-arr-single.js @@ -0,0 +1,56 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-spread-arr-single.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: Use yield value in a array spread position (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + Array Initializer + + SpreadElement[Yield, Await]: + ...AssignmentExpression[+In, ?Yield, ?Await] + +---*/ +var arr = ['a', 'b', 'c']; + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield [...yield]; +}} + +var gen = C.gen; + +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/statements/class/async-gen-method-static/yield-spread-obj.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-spread-obj.js new file mode 100644 index 0000000000..dc5be5b91e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-spread-obj.js @@ -0,0 +1,59 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-spread-obj.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: Use yield value in a object spread position (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [object-spread, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + Spread Properties + + PropertyDefinition[Yield]: + (...) + ...AssignmentExpression[In, ?Yield] + +---*/ + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield { + ...yield, + y: 1, + ...yield yield, + }; +}} + +var gen = C.gen; + +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/statements/class/async-gen-method-static/yield-star-async-next.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-async-next.js new file mode 100644 index 0000000000..05ee32010d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-async-next.js @@ -0,0 +1,226 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-async-next.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: Execution order for yield* with async iterator and next() (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, async-iteration, Symbol.asyncIterator] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { 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; + +class C { static async *gen() { + callCount += 1; + log.push({ name: "before yield*" }); + var v = yield* obj; + log.push({ + name: "after yield*", + value: v + }); + return "return-value"; + +}} + +var gen = C.gen; + +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/statements/class/async-gen-method-static/yield-star-async-return.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-async-return.js new file mode 100644 index 0000000000..4b3cc6a36d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-async-return.js @@ -0,0 +1,242 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-async-return.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: execution order for yield* with async iterator and return() (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration, Symbol.asyncIterator] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { 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; + +class C { static async *gen() { + callCount += 1; + log.push({ name: "before yield*" }); + yield* obj; + +}} + +var gen = C.gen; + +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/statements/class/async-gen-method-static/yield-star-async-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-async-throw.js new file mode 100644 index 0000000000..15c8c04084 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-async-throw.js @@ -0,0 +1,250 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-async-throw.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: execution order for yield* with async iterator and throw() (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration, Symbol.asyncIterator] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { 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; + +class C { static async *gen() { + callCount += 1; + log.push({ name: "before yield*" }); + var v = yield* obj; + log.push({ + name: "after yield*", + value: v + }); + return "return-value"; + +}} + +var gen = C.gen; + +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/statements/class/async-gen-method-static/yield-star-expr-abrupt.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-expr-abrupt.js new file mode 100644 index 0000000000..6389d5345b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-expr-abrupt.js @@ -0,0 +1,61 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-expr-abrupt.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: Abrupt completion while getting yield* operand (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { 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; + +class C { static async *gen() { + callCount += 1; + yield* abrupt(); + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +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/statements/class/async-gen-method-static/yield-star-getiter-async-get-abrupt.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-get-abrupt.js new file mode 100644 index 0000000000..48307a3ce3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-get-abrupt.js @@ -0,0 +1,81 @@ +// |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-class-decl-static-method.template +/*--- +description: Abrupt completion while getting [Symbol.asyncIterator] (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { 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; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +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/statements/class/async-gen-method-static/yield-star-getiter-async-not-callable-boolean-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-not-callable-boolean-throw.js new file mode 100644 index 0000000000..3403913eaa --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-not-callable-boolean-throw.js @@ -0,0 +1,80 @@ +// |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-class-decl-static-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.asyncIterator] (boolean) (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { 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; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +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/statements/class/async-gen-method-static/yield-star-getiter-async-not-callable-number-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-not-callable-number-throw.js new file mode 100644 index 0000000000..979a5d2798 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-not-callable-number-throw.js @@ -0,0 +1,80 @@ +// |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-class-decl-static-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.asyncIterator] (number) (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { 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; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +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/statements/class/async-gen-method-static/yield-star-getiter-async-not-callable-object-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-not-callable-object-throw.js new file mode 100644 index 0000000000..37be5fcdf5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-not-callable-object-throw.js @@ -0,0 +1,80 @@ +// |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-class-decl-static-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.asyncIterator] (object) (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { 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; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +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/statements/class/async-gen-method-static/yield-star-getiter-async-not-callable-string-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-not-callable-string-throw.js new file mode 100644 index 0000000000..c536648457 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-not-callable-string-throw.js @@ -0,0 +1,80 @@ +// |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-class-decl-static-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.asyncIterator] (string) (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { 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; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +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/statements/class/async-gen-method-static/yield-star-getiter-async-not-callable-symbol-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-not-callable-symbol-throw.js new file mode 100644 index 0000000000..6acc648eb0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-not-callable-symbol-throw.js @@ -0,0 +1,80 @@ +// |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-class-decl-static-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.asyncIterator] (symbol) (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { 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; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +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/statements/class/async-gen-method-static/yield-star-getiter-async-null-sync-get-abrupt.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-null-sync-get-abrupt.js new file mode 100644 index 0000000000..37e1fe413e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-null-sync-get-abrupt.js @@ -0,0 +1,86 @@ +// |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-class-decl-static-method.template +/*--- +description: Abrupt completion while getting @@iterator after null @@asyncIterator (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { 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; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +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/statements/class/async-gen-method-static/yield-star-getiter-async-returns-abrupt.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-returns-abrupt.js new file mode 100644 index 0000000000..17bd7eeed7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-returns-abrupt.js @@ -0,0 +1,77 @@ +// |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-class-decl-static-method.template +/*--- +description: Abrupt completion while calling [Symbol.asyncIterator] (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { 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; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +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/statements/class/async-gen-method-static/yield-star-getiter-async-returns-boolean-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-returns-boolean-throw.js new file mode 100644 index 0000000000..6d73237afe --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-returns-boolean-throw.js @@ -0,0 +1,77 @@ +// |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-class-decl-static-method.template +/*--- +description: Non object returned by [Symbol.asyncIterator]() - boolean (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { 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; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +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/statements/class/async-gen-method-static/yield-star-getiter-async-returns-null-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-returns-null-throw.js new file mode 100644 index 0000000000..eab29d7628 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-returns-null-throw.js @@ -0,0 +1,77 @@ +// |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-class-decl-static-method.template +/*--- +description: Non object returned by [Symbol.asyncIterator]() - null (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { 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; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +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/statements/class/async-gen-method-static/yield-star-getiter-async-returns-number-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-returns-number-throw.js new file mode 100644 index 0000000000..2affab6fed --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-returns-number-throw.js @@ -0,0 +1,77 @@ +// |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-class-decl-static-method.template +/*--- +description: Non object returned by [Symbol.asyncIterator]() - number (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { 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; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +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/statements/class/async-gen-method-static/yield-star-getiter-async-returns-string-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-returns-string-throw.js new file mode 100644 index 0000000000..6fb7db7086 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-returns-string-throw.js @@ -0,0 +1,77 @@ +// |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-class-decl-static-method.template +/*--- +description: Non object returned by [Symbol.asyncIterator]() - string (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { 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; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +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/statements/class/async-gen-method-static/yield-star-getiter-async-returns-symbol-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-returns-symbol-throw.js new file mode 100644 index 0000000000..e2d4c6438d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-returns-symbol-throw.js @@ -0,0 +1,77 @@ +// |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-class-decl-static-method.template +/*--- +description: Non object returned by [Symbol.asyncIterator]() - symbol (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { 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; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +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/statements/class/async-gen-method-static/yield-star-getiter-async-returns-undefined-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-returns-undefined-throw.js new file mode 100644 index 0000000000..0271cdef4c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-returns-undefined-throw.js @@ -0,0 +1,77 @@ +// |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-class-decl-static-method.template +/*--- +description: Non object returned by [Symbol.asyncIterator]() - undefined (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { 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; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +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/statements/class/async-gen-method-static/yield-star-getiter-async-undefined-sync-get-abrupt.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-undefined-sync-get-abrupt.js new file mode 100644 index 0000000000..82f09b446e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-undefined-sync-get-abrupt.js @@ -0,0 +1,86 @@ +// |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-class-decl-static-method.template +/*--- +description: Abrupt completion while getting @@iterator after undefined @@asyncIterator (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { 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; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +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/statements/class/async-gen-method-static/yield-star-getiter-sync-get-abrupt.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-sync-get-abrupt.js new file mode 100644 index 0000000000..33d910c1a1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-sync-get-abrupt.js @@ -0,0 +1,80 @@ +// |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-class-decl-static-method.template +/*--- +description: Abrupt completion while getting [Symbol.iterator] (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { 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; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +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/statements/class/async-gen-method-static/yield-star-getiter-sync-not-callable-boolean-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-sync-not-callable-boolean-throw.js new file mode 100644 index 0000000000..256bfc66e4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-sync-not-callable-boolean-throw.js @@ -0,0 +1,79 @@ +// |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-class-decl-static-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.iterator] (boolean) (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { 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; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +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/statements/class/async-gen-method-static/yield-star-getiter-sync-not-callable-number-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-sync-not-callable-number-throw.js new file mode 100644 index 0000000000..ab6f71205f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-sync-not-callable-number-throw.js @@ -0,0 +1,79 @@ +// |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-class-decl-static-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.iterator] (number) (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { 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; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +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/statements/class/async-gen-method-static/yield-star-getiter-sync-not-callable-object-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-sync-not-callable-object-throw.js new file mode 100644 index 0000000000..ff0f0108f8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-sync-not-callable-object-throw.js @@ -0,0 +1,79 @@ +// |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-class-decl-static-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.iterator] (object) (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { 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; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +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/statements/class/async-gen-method-static/yield-star-getiter-sync-not-callable-string-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-sync-not-callable-string-throw.js new file mode 100644 index 0000000000..eabfeae9d4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-sync-not-callable-string-throw.js @@ -0,0 +1,79 @@ +// |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-class-decl-static-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.iterator] (string) (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { 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; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +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/statements/class/async-gen-method-static/yield-star-getiter-sync-not-callable-symbol-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-sync-not-callable-symbol-throw.js new file mode 100644 index 0000000000..387dd91524 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-sync-not-callable-symbol-throw.js @@ -0,0 +1,79 @@ +// |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-class-decl-static-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.iterator] (symbol) (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { 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; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +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/statements/class/async-gen-method-static/yield-star-getiter-sync-returns-abrupt.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-sync-returns-abrupt.js new file mode 100644 index 0000000000..8ebcd59b6b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-sync-returns-abrupt.js @@ -0,0 +1,74 @@ +// |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-class-decl-static-method.template +/*--- +description: Abrupt completion while calling [Symbol.iterator] (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { 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; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +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/statements/class/async-gen-method-static/yield-star-getiter-sync-returns-boolean-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-sync-returns-boolean-throw.js new file mode 100644 index 0000000000..fc863e3bfc --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-sync-returns-boolean-throw.js @@ -0,0 +1,79 @@ +// |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-class-decl-static-method.template +/*--- +description: Non object returned by [Symbol.iterator]() - boolean (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { 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; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +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/statements/class/async-gen-method-static/yield-star-getiter-sync-returns-null-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-sync-returns-null-throw.js new file mode 100644 index 0000000000..b5d48b88ca --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-sync-returns-null-throw.js @@ -0,0 +1,79 @@ +// |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-class-decl-static-method.template +/*--- +description: Non object returned by [Symbol.iterator]() - null (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { 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; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +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/statements/class/async-gen-method-static/yield-star-getiter-sync-returns-number-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-sync-returns-number-throw.js new file mode 100644 index 0000000000..cdc15f4b09 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-sync-returns-number-throw.js @@ -0,0 +1,79 @@ +// |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-class-decl-static-method.template +/*--- +description: Non object returned by [Symbol.iterator]() - number (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { 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; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +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/statements/class/async-gen-method-static/yield-star-getiter-sync-returns-string-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-sync-returns-string-throw.js new file mode 100644 index 0000000000..9370a13561 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-sync-returns-string-throw.js @@ -0,0 +1,79 @@ +// |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-class-decl-static-method.template +/*--- +description: Non object returned by [Symbol.iterator]() - string (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { 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; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +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/statements/class/async-gen-method-static/yield-star-getiter-sync-returns-symbol-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-sync-returns-symbol-throw.js new file mode 100644 index 0000000000..e04e09b272 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-sync-returns-symbol-throw.js @@ -0,0 +1,79 @@ +// |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-class-decl-static-method.template +/*--- +description: Non object returned by [Symbol.iterator]() - symbol (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { 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; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +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/statements/class/async-gen-method-static/yield-star-getiter-sync-returns-undefined-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-sync-returns-undefined-throw.js new file mode 100644 index 0000000000..afdf0ef493 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-sync-returns-undefined-throw.js @@ -0,0 +1,79 @@ +// |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-class-decl-static-method.template +/*--- +description: Non object returned by [Symbol.iterator]() - undefined (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { 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; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +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/statements/class/async-gen-method-static/yield-star-next-call-done-get-abrupt.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-call-done-get-abrupt.js new file mode 100644 index 0000000000..c601d51199 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-call-done-get-abrupt.js @@ -0,0 +1,80 @@ +// |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-class-decl-static-method.template +/*--- +description: Abrupt completion while getting done (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { 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; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +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/statements/class/async-gen-method-static/yield-star-next-call-returns-abrupt.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-call-returns-abrupt.js new file mode 100644 index 0000000000..1a6db5d8a8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-call-returns-abrupt.js @@ -0,0 +1,72 @@ +// |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-class-decl-static-method.template +/*--- +description: Abrupt completion while calling next (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { 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; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +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/statements/class/async-gen-method-static/yield-star-next-call-value-get-abrupt.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-call-value-get-abrupt.js new file mode 100644 index 0000000000..0b5990c744 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-call-value-get-abrupt.js @@ -0,0 +1,82 @@ +// |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-class-decl-static-method.template +/*--- +description: Abrupt completion while getting value (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { 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; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +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/statements/class/async-gen-method-static/yield-star-next-get-abrupt.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-get-abrupt.js new file mode 100644 index 0000000000..d27e07f33b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-get-abrupt.js @@ -0,0 +1,72 @@ +// |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-class-decl-static-method.template +/*--- +description: Abrupt completion while getting next (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { 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; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +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/statements/class/async-gen-method-static/yield-star-next-non-object-ignores-then.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-non-object-ignores-then.js new file mode 100644 index 0000000000..53a7eff8e1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-non-object-ignores-then.js @@ -0,0 +1,92 @@ +// |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-class-decl-static-method.template +/*--- +description: If next() value is not-object, do not access respective then property (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { 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; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +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/statements/class/async-gen-method-static/yield-star-next-not-callable-boolean-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-not-callable-boolean-throw.js new file mode 100644 index 0000000000..d6bcf220ec --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-not-callable-boolean-throw.js @@ -0,0 +1,69 @@ +// |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-class-decl-static-method.template +/*--- +description: Not-callable next value in a yield star position - boolean (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { 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; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +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/statements/class/async-gen-method-static/yield-star-next-not-callable-null-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-not-callable-null-throw.js new file mode 100644 index 0000000000..b2c8f1e8a6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-not-callable-null-throw.js @@ -0,0 +1,69 @@ +// |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-class-decl-static-method.template +/*--- +description: Not-callable next value in a yield star position - null (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { 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; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +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/statements/class/async-gen-method-static/yield-star-next-not-callable-number-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-not-callable-number-throw.js new file mode 100644 index 0000000000..dbbf208489 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-not-callable-number-throw.js @@ -0,0 +1,69 @@ +// |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-class-decl-static-method.template +/*--- +description: Not-callable next value in a yield star position - number (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { 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; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +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/statements/class/async-gen-method-static/yield-star-next-not-callable-object-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-not-callable-object-throw.js new file mode 100644 index 0000000000..298c964de5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-not-callable-object-throw.js @@ -0,0 +1,69 @@ +// |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-class-decl-static-method.template +/*--- +description: Not-callable next value in a yield star position - object (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { 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; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +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/statements/class/async-gen-method-static/yield-star-next-not-callable-string-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-not-callable-string-throw.js new file mode 100644 index 0000000000..9ebbf19402 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-not-callable-string-throw.js @@ -0,0 +1,69 @@ +// |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-class-decl-static-method.template +/*--- +description: Not-callable next value in a yield star position - string (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { 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; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +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/statements/class/async-gen-method-static/yield-star-next-not-callable-symbol-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-not-callable-symbol-throw.js new file mode 100644 index 0000000000..b61aeb91d5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-not-callable-symbol-throw.js @@ -0,0 +1,69 @@ +// |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-class-decl-static-method.template +/*--- +description: Not-callable next value in a yield star position - symbol (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { 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; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +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/statements/class/async-gen-method-static/yield-star-next-not-callable-undefined-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-not-callable-undefined-throw.js new file mode 100644 index 0000000000..74031fa546 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-not-callable-undefined-throw.js @@ -0,0 +1,69 @@ +// |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-class-decl-static-method.template +/*--- +description: Not-callable next value in a yield star position - undefined (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { 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; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +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/statements/class/async-gen-method-static/yield-star-next-then-get-abrupt.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-then-get-abrupt.js new file mode 100644 index 0000000000..573faffd03 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-then-get-abrupt.js @@ -0,0 +1,96 @@ +// |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-class-decl-static-method.template +/*--- +description: Return abrupt after getting next().then (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { 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; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +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/statements/class/async-gen-method-static/yield-star-next-then-non-callable-boolean-fulfillpromise.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-then-non-callable-boolean-fulfillpromise.js new file mode 100644 index 0000000000..05c76f2658 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-then-non-callable-boolean-fulfillpromise.js @@ -0,0 +1,90 @@ +// |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-class-decl-static-method.template +/*--- +description: FulfillPromise if next().then is not-callable (boolean) (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { 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; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}} + +var gen = C.gen; + +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/statements/class/async-gen-method-static/yield-star-next-then-non-callable-null-fulfillpromise.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-then-non-callable-null-fulfillpromise.js new file mode 100644 index 0000000000..c789fadca3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-then-non-callable-null-fulfillpromise.js @@ -0,0 +1,90 @@ +// |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-class-decl-static-method.template +/*--- +description: FulfillPromise if next().then is not-callable (null) (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { 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; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}} + +var gen = C.gen; + +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/statements/class/async-gen-method-static/yield-star-next-then-non-callable-number-fulfillpromise.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-then-non-callable-number-fulfillpromise.js new file mode 100644 index 0000000000..ef1ebee1d6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-then-non-callable-number-fulfillpromise.js @@ -0,0 +1,90 @@ +// |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-class-decl-static-method.template +/*--- +description: FulfillPromise if next().then is not-callable (number) (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { 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; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}} + +var gen = C.gen; + +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/statements/class/async-gen-method-static/yield-star-next-then-non-callable-object-fulfillpromise.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-then-non-callable-object-fulfillpromise.js new file mode 100644 index 0000000000..f56613fafe --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-then-non-callable-object-fulfillpromise.js @@ -0,0 +1,90 @@ +// |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-class-decl-static-method.template +/*--- +description: FulfillPromise if next().then is not-callable (object) (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { 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; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}} + +var gen = C.gen; + +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/statements/class/async-gen-method-static/yield-star-next-then-non-callable-string-fulfillpromise.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-then-non-callable-string-fulfillpromise.js new file mode 100644 index 0000000000..5d9ee1aaa1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-then-non-callable-string-fulfillpromise.js @@ -0,0 +1,90 @@ +// |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-class-decl-static-method.template +/*--- +description: FulfillPromise if next().then is not-callable (string) (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { 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; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}} + +var gen = C.gen; + +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/statements/class/async-gen-method-static/yield-star-next-then-non-callable-symbol-fulfillpromise.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-then-non-callable-symbol-fulfillpromise.js new file mode 100644 index 0000000000..baf92f8f13 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-then-non-callable-symbol-fulfillpromise.js @@ -0,0 +1,90 @@ +// |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-class-decl-static-method.template +/*--- +description: FulfillPromise if next().then is not-callable (symbol) (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { 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; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}} + +var gen = C.gen; + +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/statements/class/async-gen-method-static/yield-star-next-then-non-callable-undefined-fulfillpromise.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-then-non-callable-undefined-fulfillpromise.js new file mode 100644 index 0000000000..db0df04520 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-then-non-callable-undefined-fulfillpromise.js @@ -0,0 +1,90 @@ +// |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-class-decl-static-method.template +/*--- +description: FulfillPromise if next().then is not-callable (undefined) (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { 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; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}} + +var gen = C.gen; + +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/statements/class/async-gen-method-static/yield-star-next-then-returns-abrupt.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-then-returns-abrupt.js new file mode 100644 index 0000000000..92987f9a33 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-then-returns-abrupt.js @@ -0,0 +1,96 @@ +// |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-class-decl-static-method.template +/*--- +description: Return abrupt after calling next().then (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { 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; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +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/statements/class/async-gen-method-static/yield-star-sync-next.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-sync-next.js new file mode 100644 index 0000000000..b6bb6ad955 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-sync-next.js @@ -0,0 +1,229 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-sync-next.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: execution order for yield* with sync iterator and next() (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, async-iteration, Symbol.asyncIterator] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { 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; + +class C { static async *gen() { + callCount += 1; + log.push({ name: "before yield*" }); + var v = yield* obj; + log.push({ + name: "after yield*", + value: v + }); + return "return-value"; + +}} + +var gen = C.gen; + +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/statements/class/async-gen-method-static/yield-star-sync-return.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-sync-return.js new file mode 100644 index 0000000000..f83ce21dd5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-sync-return.js @@ -0,0 +1,204 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-sync-return.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: execution order for yield* with sync iterator and return() (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, async-iteration, Symbol.asyncIterator] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { 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; + +class C { static async *gen() { + callCount += 1; + log.push({ name: "before yield*" }); + yield* obj; + +}} + +var gen = C.gen; + +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/statements/class/async-gen-method-static/yield-star-sync-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-sync-throw.js new file mode 100644 index 0000000000..6924d9f8e6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-sync-throw.js @@ -0,0 +1,210 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-sync-throw.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: execution order for yield* with sync iterator and throw() (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { 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; + +class C { static async *gen() { + callCount += 1; + log.push({ name: "before yield*" }); + var v = yield* obj; + log.push({ + name: "after yield*", + value: v + }); + return "return-value"; + +}} + +var gen = C.gen; + +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); |