diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
commit | 2aa4a82499d4becd2284cdb482213d541b8804dd (patch) | |
tree | b80bf8bf13c3766139fbacc530efd0dd9d54394c /js/src/tests/test262/language/expressions/class/async-method-static | |
parent | Initial commit. (diff) | |
download | firefox-upstream.tar.xz firefox-upstream.zip |
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/language/expressions/class/async-method-static')
40 files changed, 1999 insertions, 0 deletions
diff --git a/js/src/tests/test262/language/expressions/class/async-method-static/array-destructuring-param-strict-body.js b/js/src/tests/test262/language/expressions/class/async-method-static/array-destructuring-param-strict-body.js new file mode 100644 index 0000000000..8f77cfc9cf --- /dev/null +++ b/js/src/tests/test262/language/expressions/class/async-method-static/array-destructuring-param-strict-body.js @@ -0,0 +1,136 @@ +// |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-expr-async-meth-static.template +/*--- +description: ArrayBindingPattern and Use Strict Directive are not allowed to coexist for the same function. (static class expression async method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [rest-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. 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 + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncMethod is strict mode code, let strict be true. Otherwise + let strict be false. + 4. Let scope be the LexicalEnvironment of the running execution context. + 5. Let closure be ! AsyncFunctionCreate(Method, UniqueFormalParameters, AsyncFunctionBody, + 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(); + +var C = class { + static async method([element]) { + "use strict"; + } +}; diff --git a/js/src/tests/test262/language/expressions/class/async-method-static/await-as-binding-identifier-escaped.js b/js/src/tests/test262/language/expressions/class/async-method-static/await-as-binding-identifier-escaped.js new file mode 100644 index 0000000000..80550b48a9 --- /dev/null +++ b/js/src/tests/test262/language/expressions/class/async-method-static/await-as-binding-identifier-escaped.js @@ -0,0 +1,39 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-functions/await-as-binding-identifier-escaped.case +// - src/async-functions/syntax/async-class-expr-static-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Static async method as a ClassExpression element) +esid: prod-AsyncMethod +features: [async-functions] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + + BindingIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +$DONOTEVALUATE(); + + +var C = class { + static async method() { + var \u0061wait; + } +}; diff --git a/js/src/tests/test262/language/expressions/class/async-method-static/await-as-binding-identifier.js b/js/src/tests/test262/language/expressions/class/async-method-static/await-as-binding-identifier.js new file mode 100644 index 0000000000..d09801447c --- /dev/null +++ b/js/src/tests/test262/language/expressions/class/async-method-static/await-as-binding-identifier.js @@ -0,0 +1,39 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-functions/await-as-binding-identifier.case +// - src/async-functions/syntax/async-class-expr-static-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Static async method as a ClassExpression element) +esid: prod-AsyncMethod +features: [async-functions] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + + BindingIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +$DONOTEVALUATE(); + + +var C = class { + static async method() { + var await; + } +}; diff --git a/js/src/tests/test262/language/expressions/class/async-method-static/await-as-identifier-reference-escaped.js b/js/src/tests/test262/language/expressions/class/async-method-static/await-as-identifier-reference-escaped.js new file mode 100644 index 0000000000..2c80f653fd --- /dev/null +++ b/js/src/tests/test262/language/expressions/class/async-method-static/await-as-identifier-reference-escaped.js @@ -0,0 +1,39 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-functions/await-as-identifier-reference-escaped.case +// - src/async-functions/syntax/async-class-expr-static-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Static async method as a ClassExpression element) +esid: prod-AsyncMethod +features: [async-functions] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + + IdentifierReference : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +$DONOTEVALUATE(); + + +var C = class { + static async method() { + void \u0061wait; + } +}; diff --git a/js/src/tests/test262/language/expressions/class/async-method-static/await-as-identifier-reference.js b/js/src/tests/test262/language/expressions/class/async-method-static/await-as-identifier-reference.js new file mode 100644 index 0000000000..259d8880c2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/class/async-method-static/await-as-identifier-reference.js @@ -0,0 +1,39 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-functions/await-as-identifier-reference.case +// - src/async-functions/syntax/async-class-expr-static-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Static async method as a ClassExpression element) +esid: prod-AsyncMethod +features: [async-functions] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + + IdentifierReference : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +$DONOTEVALUATE(); + + +var C = class { + static async method() { + void await; + } +}; diff --git a/js/src/tests/test262/language/expressions/class/async-method-static/await-as-label-identifier-escaped.js b/js/src/tests/test262/language/expressions/class/async-method-static/await-as-label-identifier-escaped.js new file mode 100644 index 0000000000..c7a17cb1f5 --- /dev/null +++ b/js/src/tests/test262/language/expressions/class/async-method-static/await-as-label-identifier-escaped.js @@ -0,0 +1,39 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-functions/await-as-label-identifier-escaped.case +// - src/async-functions/syntax/async-class-expr-static-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a label identifier. (Static async method as a ClassExpression element) +esid: prod-AsyncMethod +features: [async-functions] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + + LabelIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +$DONOTEVALUATE(); + + +var C = class { + static async method() { + \u0061wait: ; + } +}; diff --git a/js/src/tests/test262/language/expressions/class/async-method-static/await-as-label-identifier.js b/js/src/tests/test262/language/expressions/class/async-method-static/await-as-label-identifier.js new file mode 100644 index 0000000000..518a5ac331 --- /dev/null +++ b/js/src/tests/test262/language/expressions/class/async-method-static/await-as-label-identifier.js @@ -0,0 +1,39 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-functions/await-as-label-identifier.case +// - src/async-functions/syntax/async-class-expr-static-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a label identifier. (Static async method as a ClassExpression element) +esid: prod-AsyncMethod +features: [async-functions] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + + LabelIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +$DONOTEVALUATE(); + + +var C = class { + static async method() { + await: ; + } +}; diff --git a/js/src/tests/test262/language/expressions/class/async-method-static/browser.js b/js/src/tests/test262/language/expressions/class/async-method-static/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/class/async-method-static/browser.js diff --git a/js/src/tests/test262/language/expressions/class/async-method-static/dflt-params-abrupt.js b/js/src/tests/test262/language/expressions/class/async-method-static/dflt-params-abrupt.js new file mode 100644 index 0000000000..22b35a0196 --- /dev/null +++ b/js/src/tests/test262/language/expressions/class/async-method-static/dflt-params-abrupt.js @@ -0,0 +1,71 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-abrupt.case +// - src/function-forms/error/cls-expr-async-meth-static.template +/*--- +description: Abrupt completion returned by evaluation of initializer (static class expression async method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [default-parameters, async-functions] +flags: [generated, async] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. 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 + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncMethod is strict mode code, let strict be true. Otherwise + let strict be false. + 4. Let scope be the LexicalEnvironment of the running execution context. + 5. Let closure be ! AsyncFunctionCreate(Method, UniqueFormalParameters, AsyncFunctionBody, + scope, strict). + [...] + + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. + +---*/ + + +var callCount = 0; + +var C = class { + static async method(_ = (function() { throw new Test262Error(); }())) { + + callCount = callCount + 1; + } +}; + +C.method() + .then(_ => { + throw new Test262Error('function should not be resolved'); + }, error => assert.sameValue(error.constructor, Test262Error)) + .then(() => { + assert.sameValue(callCount, 0, 'function body is not evaluated'); + }, $DONE) + .then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/class/async-method-static/dflt-params-arg-val-not-undefined.js b/js/src/tests/test262/language/expressions/class/async-method-static/dflt-params-arg-val-not-undefined.js new file mode 100644 index 0000000000..32116025b8 --- /dev/null +++ b/js/src/tests/test262/language/expressions/class/async-method-static/dflt-params-arg-val-not-undefined.js @@ -0,0 +1,90 @@ +// |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-expr-async-meth-static.template +/*--- +description: Use of initializer when argument value is not `undefined` (static class expression async method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [default-parameters, async-functions] +flags: [generated, async] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. 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 + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncMethod is strict mode code, let strict be true. Otherwise + let strict be false. + 4. Let scope be the LexicalEnvironment of the running execution context. + 5. Let closure be ! AsyncFunctionCreate(Method, UniqueFormalParameters, AsyncFunctionBody, + 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; +var C = class { + 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).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/expressions/class/async-method-static/dflt-params-arg-val-undefined.js b/js/src/tests/test262/language/expressions/class/async-method-static/dflt-params-arg-val-undefined.js new file mode 100644 index 0000000000..ae581db2e9 --- /dev/null +++ b/js/src/tests/test262/language/expressions/class/async-method-static/dflt-params-arg-val-undefined.js @@ -0,0 +1,73 @@ +// |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-expr-async-meth-static.template +/*--- +description: Use of initializer when argument value is `undefined` (static class expression async method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [default-parameters, async-functions] +flags: [generated, async] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. 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 + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncMethod is strict mode code, let strict be true. Otherwise + let strict be false. + 4. Let scope be the LexicalEnvironment of the running execution context. + 5. Let closure be ! AsyncFunctionCreate(Method, UniqueFormalParameters, AsyncFunctionBody, + 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; +var C = class { + 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).then(() => { + assert.sameValue(callCount, 1, 'method invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/class/async-method-static/dflt-params-duplicates.js b/js/src/tests/test262/language/expressions/class/async-method-static/dflt-params-duplicates.js new file mode 100644 index 0000000000..10bcbf3660 --- /dev/null +++ b/js/src/tests/test262/language/expressions/class/async-method-static/dflt-params-duplicates.js @@ -0,0 +1,65 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-duplicates.case +// - src/function-forms/syntax/cls-expr-async-meth-static.template +/*--- +description: It is a Syntax Error if BoundNames of FormalParameters contains any duplicate elements. (static class expression async method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. 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 + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncMethod is strict mode code, let strict be true. Otherwise + let strict be false. + 4. Let scope be the LexicalEnvironment of the running execution context. + 5. Let closure be ! AsyncFunctionCreate(Method, UniqueFormalParameters, AsyncFunctionBody, + 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(); + +var C = class { + static async method(x = 0, x) { + + } +}; diff --git a/js/src/tests/test262/language/expressions/class/async-method-static/dflt-params-ref-later.js b/js/src/tests/test262/language/expressions/class/async-method-static/dflt-params-ref-later.js new file mode 100644 index 0000000000..fdbfb6e6a8 --- /dev/null +++ b/js/src/tests/test262/language/expressions/class/async-method-static/dflt-params-ref-later.js @@ -0,0 +1,72 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-ref-later.case +// - src/function-forms/error/cls-expr-async-meth-static.template +/*--- +description: Referencing a parameter that occurs later in the ParameterList (static class expression async method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [default-parameters, async-functions] +flags: [generated, async] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. 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 + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncMethod is strict mode code, let strict be true. Otherwise + let strict be false. + 4. Let scope be the LexicalEnvironment of the running execution context. + 5. Let closure be ! AsyncFunctionCreate(Method, UniqueFormalParameters, AsyncFunctionBody, + scope, strict). + [...] + + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. + +---*/ +var x = 0; + + +var callCount = 0; + +var C = class { + static async method(x = y, y) { + + callCount = callCount + 1; + } +}; + +C.method() + .then(_ => { + throw new Test262Error('function should not be resolved'); + }, error => assert.sameValue(error.constructor, ReferenceError)) + .then(() => { + assert.sameValue(callCount, 0, 'function body is not evaluated'); + }, $DONE) + .then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/class/async-method-static/dflt-params-ref-prior.js b/js/src/tests/test262/language/expressions/class/async-method-static/dflt-params-ref-prior.js new file mode 100644 index 0000000000..2369313da7 --- /dev/null +++ b/js/src/tests/test262/language/expressions/class/async-method-static/dflt-params-ref-prior.js @@ -0,0 +1,70 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-ref-prior.case +// - src/function-forms/default/cls-expr-async-meth-static.template +/*--- +description: Referencing a parameter that occurs earlier in the ParameterList (static class expression async method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [default-parameters, async-functions] +flags: [generated, async] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. 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 + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncMethod is strict mode code, let strict be true. Otherwise + let strict be false. + 4. Let scope be the LexicalEnvironment of the running execution context. + 5. Let closure be ! AsyncFunctionCreate(Method, UniqueFormalParameters, AsyncFunctionBody, + scope, strict). + [...] + + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. + +---*/ +var x = 0; + +var callCount = 0; +var C = class { + 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).then(() => { + assert.sameValue(callCount, 1, 'method invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/class/async-method-static/dflt-params-ref-self.js b/js/src/tests/test262/language/expressions/class/async-method-static/dflt-params-ref-self.js new file mode 100644 index 0000000000..4106664cbd --- /dev/null +++ b/js/src/tests/test262/language/expressions/class/async-method-static/dflt-params-ref-self.js @@ -0,0 +1,72 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-ref-self.case +// - src/function-forms/error/cls-expr-async-meth-static.template +/*--- +description: Referencing a parameter from within its own initializer (static class expression async method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [default-parameters, async-functions] +flags: [generated, async] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. 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 + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncMethod is strict mode code, let strict be true. Otherwise + let strict be false. + 4. Let scope be the LexicalEnvironment of the running execution context. + 5. Let closure be ! AsyncFunctionCreate(Method, UniqueFormalParameters, AsyncFunctionBody, + scope, strict). + [...] + + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. + +---*/ +var x = 0; + + +var callCount = 0; + +var C = class { + static async method(x = x) { + + callCount = callCount + 1; + } +}; + +C.method() + .then(_ => { + throw new Test262Error('function should not be resolved'); + }, error => assert.sameValue(error.constructor, ReferenceError)) + .then(() => { + assert.sameValue(callCount, 0, 'function body is not evaluated'); + }, $DONE) + .then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/class/async-method-static/dflt-params-rest.js b/js/src/tests/test262/language/expressions/class/async-method-static/dflt-params-rest.js new file mode 100644 index 0000000000..892b04cd31 --- /dev/null +++ b/js/src/tests/test262/language/expressions/class/async-method-static/dflt-params-rest.js @@ -0,0 +1,69 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-rest.case +// - src/function-forms/syntax/cls-expr-async-meth-static.template +/*--- +description: RestParameter does not support an initializer (static class expression async method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. 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 + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncMethod is strict mode code, let strict be true. Otherwise + let strict be false. + 4. Let scope be the LexicalEnvironment of the running execution context. + 5. Let closure be ! AsyncFunctionCreate(Method, UniqueFormalParameters, AsyncFunctionBody, + 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(); + +var C = class { + static async method(...x = []) { + + } +}; diff --git a/js/src/tests/test262/language/expressions/class/async-method-static/dflt-params-trailing-comma.js b/js/src/tests/test262/language/expressions/class/async-method-static/dflt-params-trailing-comma.js new file mode 100644 index 0000000000..a678481d43 --- /dev/null +++ b/js/src/tests/test262/language/expressions/class/async-method-static/dflt-params-trailing-comma.js @@ -0,0 +1,65 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-trailing-comma.case +// - src/function-forms/default/cls-expr-async-meth-static.template +/*--- +description: A trailing comma should not increase the respective length, using default parameters (static class expression async method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-functions] +flags: [generated, async] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. 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 + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncMethod is strict mode code, let strict be true. Otherwise + let strict be false. + 4. Let scope be the LexicalEnvironment of the running execution context. + 5. Let closure be ! AsyncFunctionCreate(Method, UniqueFormalParameters, AsyncFunctionBody, + scope, strict). + [...] + + + Trailing comma in the parameters list + + 14.1 Function Definitions + + FormalParameters[Yield, Await] : FormalParameterList[?Yield, ?Await] , +---*/ + +var callCount = 0; +var C = class { + 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).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/expressions/class/async-method-static/forbidden-ext/b1/browser.js b/js/src/tests/test262/language/expressions/class/async-method-static/forbidden-ext/b1/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/class/async-method-static/forbidden-ext/b1/browser.js diff --git a/js/src/tests/test262/language/expressions/class/async-method-static/forbidden-ext/b1/cls-expr-async-meth-static-forbidden-ext-direct-access-prop-arguments.js b/js/src/tests/test262/language/expressions/class/async-method-static/forbidden-ext/b1/cls-expr-async-meth-static-forbidden-ext-direct-access-prop-arguments.js new file mode 100644 index 0000000000..c849102c33 --- /dev/null +++ b/js/src/tests/test262/language/expressions/class/async-method-static/forbidden-ext/b1/cls-expr-async-meth-static-forbidden-ext-direct-access-prop-arguments.js @@ -0,0 +1,40 @@ +// |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-expr-async-meth-static.template +/*--- +description: Forbidden extension, f.arguments (static class expression async method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [arrow-function, async-functions, class] +flags: [generated, noStrict, async] +info: | + ClassExpression : class BindingIdentifieropt 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; + +var C = class { + static async method() { + assert.sameValue(this.method.hasOwnProperty("arguments"), false); + callCount++; + } +}; + +C.method() + .then(() => { + assert.sameValue(callCount, 1, 'function body evaluated'); + }, $DONE).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/class/async-method-static/forbidden-ext/b1/cls-expr-async-meth-static-forbidden-ext-direct-access-prop-caller.js b/js/src/tests/test262/language/expressions/class/async-method-static/forbidden-ext/b1/cls-expr-async-meth-static-forbidden-ext-direct-access-prop-caller.js new file mode 100644 index 0000000000..bed6c42916 --- /dev/null +++ b/js/src/tests/test262/language/expressions/class/async-method-static/forbidden-ext/b1/cls-expr-async-meth-static-forbidden-ext-direct-access-prop-caller.js @@ -0,0 +1,40 @@ +// |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-expr-async-meth-static.template +/*--- +description: Forbidden extension, o.caller (static class expression async method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [arrow-function, async-functions, class] +flags: [generated, noStrict, async] +info: | + ClassExpression : class BindingIdentifieropt 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; + +var C = class { + static async method() { + assert.sameValue(this.method.hasOwnProperty("caller"), false); + callCount++; + } +}; + +C.method() + .then(() => { + assert.sameValue(callCount, 1, 'function body evaluated'); + }, $DONE).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/class/async-method-static/forbidden-ext/b1/shell.js b/js/src/tests/test262/language/expressions/class/async-method-static/forbidden-ext/b1/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/class/async-method-static/forbidden-ext/b1/shell.js diff --git a/js/src/tests/test262/language/expressions/class/async-method-static/forbidden-ext/b2/browser.js b/js/src/tests/test262/language/expressions/class/async-method-static/forbidden-ext/b2/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/class/async-method-static/forbidden-ext/b2/browser.js diff --git a/js/src/tests/test262/language/expressions/class/async-method-static/forbidden-ext/b2/cls-expr-async-meth-static-forbidden-ext-indirect-access-own-prop-caller-get.js b/js/src/tests/test262/language/expressions/class/async-method-static/forbidden-ext/b2/cls-expr-async-meth-static-forbidden-ext-indirect-access-own-prop-caller-get.js new file mode 100644 index 0000000000..f1e9a83ec7 --- /dev/null +++ b/js/src/tests/test262/language/expressions/class/async-method-static/forbidden-ext/b2/cls-expr-async-meth-static-forbidden-ext-indirect-access-own-prop-caller-get.js @@ -0,0 +1,66 @@ +// |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-expr-async-meth-static.template +/*--- +description: Forbidden extension, o.caller (static class expression async method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [arrow-function, async-functions, class] +flags: [generated, noStrict, async] +info: | + ClassExpression : class BindingIdentifieropt 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; + +var C = class { + 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() + .then(() => { + assert.sameValue(callCount, 1, 'function body evaluated'); + }, $DONE).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/class/async-method-static/forbidden-ext/b2/cls-expr-async-meth-static-forbidden-ext-indirect-access-own-prop-caller-value.js b/js/src/tests/test262/language/expressions/class/async-method-static/forbidden-ext/b2/cls-expr-async-meth-static-forbidden-ext-indirect-access-own-prop-caller-value.js new file mode 100644 index 0000000000..39d3ed26e2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/class/async-method-static/forbidden-ext/b2/cls-expr-async-meth-static-forbidden-ext-indirect-access-own-prop-caller-value.js @@ -0,0 +1,66 @@ +// |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-expr-async-meth-static.template +/*--- +description: Forbidden extension, o.caller (static class expression async method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [arrow-function, async-functions, class] +flags: [generated, noStrict, async] +info: | + ClassExpression : class BindingIdentifieropt 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; + +var C = class { + 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() + .then(() => { + assert.sameValue(callCount, 1, 'function body evaluated'); + }, $DONE).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/class/async-method-static/forbidden-ext/b2/cls-expr-async-meth-static-forbidden-ext-indirect-access-prop-caller.js b/js/src/tests/test262/language/expressions/class/async-method-static/forbidden-ext/b2/cls-expr-async-meth-static-forbidden-ext-indirect-access-prop-caller.js new file mode 100644 index 0000000000..2000c1018f --- /dev/null +++ b/js/src/tests/test262/language/expressions/class/async-method-static/forbidden-ext/b2/cls-expr-async-meth-static-forbidden-ext-indirect-access-prop-caller.js @@ -0,0 +1,66 @@ +// |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-expr-async-meth-static.template +/*--- +description: Forbidden extension, o.caller (static class expression async method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [arrow-function, async-functions, class] +flags: [generated, noStrict, async] +info: | + ClassExpression : class BindingIdentifieropt 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; + +var C = class { + 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() + .then(() => { + assert.sameValue(callCount, 1, 'function body evaluated'); + }, $DONE).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/class/async-method-static/forbidden-ext/b2/shell.js b/js/src/tests/test262/language/expressions/class/async-method-static/forbidden-ext/b2/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/class/async-method-static/forbidden-ext/b2/shell.js diff --git a/js/src/tests/test262/language/expressions/class/async-method-static/forbidden-ext/browser.js b/js/src/tests/test262/language/expressions/class/async-method-static/forbidden-ext/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/class/async-method-static/forbidden-ext/browser.js diff --git a/js/src/tests/test262/language/expressions/class/async-method-static/forbidden-ext/shell.js b/js/src/tests/test262/language/expressions/class/async-method-static/forbidden-ext/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/class/async-method-static/forbidden-ext/shell.js diff --git a/js/src/tests/test262/language/expressions/class/async-method-static/object-destructuring-param-strict-body.js b/js/src/tests/test262/language/expressions/class/async-method-static/object-destructuring-param-strict-body.js new file mode 100644 index 0000000000..ebee36b3e1 --- /dev/null +++ b/js/src/tests/test262/language/expressions/class/async-method-static/object-destructuring-param-strict-body.js @@ -0,0 +1,136 @@ +// |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-expr-async-meth-static.template +/*--- +description: ObjectBindingPattern and Use Strict Directive are not allowed to coexist for the same function. (static class expression async method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [rest-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. 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 + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncMethod is strict mode code, let strict be true. Otherwise + let strict be false. + 4. Let scope be the LexicalEnvironment of the running execution context. + 5. Let closure be ! AsyncFunctionCreate(Method, UniqueFormalParameters, AsyncFunctionBody, + 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(); + +var C = class { + static async method({property}) { + "use strict"; + } +}; diff --git a/js/src/tests/test262/language/expressions/class/async-method-static/params-trailing-comma-multiple.js b/js/src/tests/test262/language/expressions/class/async-method-static/params-trailing-comma-multiple.js new file mode 100644 index 0000000000..9245a36899 --- /dev/null +++ b/js/src/tests/test262/language/expressions/class/async-method-static/params-trailing-comma-multiple.js @@ -0,0 +1,65 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/params-trailing-comma-multiple.case +// - src/function-forms/default/cls-expr-async-meth-static.template +/*--- +description: A trailing comma should not increase the respective length, using multiple parameters (static class expression async method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-functions] +flags: [generated, async] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. 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 + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncMethod is strict mode code, let strict be true. Otherwise + let strict be false. + 4. Let scope be the LexicalEnvironment of the running execution context. + 5. Let closure be ! AsyncFunctionCreate(Method, UniqueFormalParameters, AsyncFunctionBody, + scope, strict). + [...] + + + Trailing comma in the parameters list + + 14.1 Function Definitions + + FormalParameters[Yield, Await] : FormalParameterList[?Yield, ?Await] , +---*/ + +var callCount = 0; +var C = class { + 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).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/expressions/class/async-method-static/params-trailing-comma-single.js b/js/src/tests/test262/language/expressions/class/async-method-static/params-trailing-comma-single.js new file mode 100644 index 0000000000..5589610434 --- /dev/null +++ b/js/src/tests/test262/language/expressions/class/async-method-static/params-trailing-comma-single.js @@ -0,0 +1,64 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/params-trailing-comma-single.case +// - src/function-forms/default/cls-expr-async-meth-static.template +/*--- +description: A trailing comma should not increase the respective length, using a single parameter (static class expression async method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-functions] +flags: [generated, async] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. 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 + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncMethod is strict mode code, let strict be true. Otherwise + let strict be false. + 4. Let scope be the LexicalEnvironment of the running execution context. + 5. Let closure be ! AsyncFunctionCreate(Method, UniqueFormalParameters, AsyncFunctionBody, + scope, strict). + [...] + + + Trailing comma in the parameters list + + 14.1 Function Definitions + + FormalParameters[Yield, Await] : FormalParameterList[?Yield, ?Await] , +---*/ + +var callCount = 0; +var C = class { + 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).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/expressions/class/async-method-static/rest-param-strict-body.js b/js/src/tests/test262/language/expressions/class/async-method-static/rest-param-strict-body.js new file mode 100644 index 0000000000..438c8cd629 --- /dev/null +++ b/js/src/tests/test262/language/expressions/class/async-method-static/rest-param-strict-body.js @@ -0,0 +1,136 @@ +// |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-expr-async-meth-static.template +/*--- +description: RestParameter and Use Strict Directive are not allowed to coexist for the same function. (static class expression async method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [rest-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. 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 + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncMethod is strict mode code, let strict be true. Otherwise + let strict be false. + 4. Let scope be the LexicalEnvironment of the running execution context. + 5. Let closure be ! AsyncFunctionCreate(Method, UniqueFormalParameters, AsyncFunctionBody, + 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(); + +var C = class { + static async method(a,...rest) { + "use strict"; + } +}; diff --git a/js/src/tests/test262/language/expressions/class/async-method-static/rest-params-trailing-comma-early-error.js b/js/src/tests/test262/language/expressions/class/async-method-static/rest-params-trailing-comma-early-error.js new file mode 100644 index 0000000000..a3d2b167d8 --- /dev/null +++ b/js/src/tests/test262/language/expressions/class/async-method-static/rest-params-trailing-comma-early-error.js @@ -0,0 +1,61 @@ +// |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-expr-async-meth-static.template +/*--- +description: It's a syntax error if a FunctionRestParameter is followed by a trailing comma (static class expression async method) +esid: sec-class-definitions-runtime-semantics-evaluation +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. 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 + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncMethod is strict mode code, let strict be true. Otherwise + let strict be false. + 4. Let scope be the LexicalEnvironment of the running execution context. + 5. Let closure be ! AsyncFunctionCreate(Method, UniqueFormalParameters, AsyncFunctionBody, + 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(); + +var C = class { + static async method(...a,) { + + } +}; diff --git a/js/src/tests/test262/language/expressions/class/async-method-static/returns-async-arrow-returns-arguments-from-parent-function.js b/js/src/tests/test262/language/expressions/class/async-method-static/returns-async-arrow-returns-arguments-from-parent-function.js new file mode 100644 index 0000000000..0bbe6ede08 --- /dev/null +++ b/js/src/tests/test262/language/expressions/class/async-method-static/returns-async-arrow-returns-arguments-from-parent-function.js @@ -0,0 +1,41 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-functions/returns-async-arrow-returns-arguments-from-parent-function.case +// - src/async-functions/evaluation/async-class-expr-static-method.template +/*--- +description: Async function returns an async function. (Static async method as a ClassExpression element) +esid: prod-AsyncMethod +features: [async-functions] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + +---*/ +let count = 0; + + +var C = class { + static async method(x) { + let a = arguments; + return async () => a === arguments; + } +}; +// Stores a reference `asyncFn` for case evaluation +let asyncFn = C.method; + +asyncFn().then(retFn => { + count++; + return retFn(); +}).then(result => { + assert.sameValue(result, true); + assert.sameValue(count, 1); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/class/async-method-static/returns-async-arrow-returns-newtarget.js b/js/src/tests/test262/language/expressions/class/async-method-static/returns-async-arrow-returns-newtarget.js new file mode 100644 index 0000000000..a7895ab6bf --- /dev/null +++ b/js/src/tests/test262/language/expressions/class/async-method-static/returns-async-arrow-returns-newtarget.js @@ -0,0 +1,40 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-functions/returns-async-arrow-returns-newtarget.case +// - src/async-functions/evaluation/async-class-expr-static-method.template +/*--- +description: Async function returns an async function. (Static async method as a ClassExpression element) +esid: prod-AsyncMethod +features: [async-functions] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + +---*/ +let count = 0; + + +var C = class { + static async method(x) { + return async () => new.target; + } +}; +// Stores a reference `asyncFn` for case evaluation +let asyncFn = C.method; + +asyncFn().then(retFn => { + count++; + return retFn(); +}).then(result => { + assert.sameValue(result, undefined); + assert.sameValue(count, 1); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/class/async-method-static/returns-async-arrow.js b/js/src/tests/test262/language/expressions/class/async-method-static/returns-async-arrow.js new file mode 100644 index 0000000000..42514c802f --- /dev/null +++ b/js/src/tests/test262/language/expressions/class/async-method-static/returns-async-arrow.js @@ -0,0 +1,40 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-functions/returns-async-arrow.case +// - src/async-functions/evaluation/async-class-expr-static-method.template +/*--- +description: Async function returns an async function. (Static async method as a ClassExpression element) +esid: prod-AsyncMethod +features: [async-functions] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + +---*/ +let count = 0; + + +var C = class { + static async method(x) { + return async () => x; + } +}; +// Stores a reference `asyncFn` for case evaluation +let asyncFn = C.method; + +asyncFn(1).then(retFn => { + count++; + return retFn(); +}).then(result => { + assert.sameValue(result, 1); + assert.sameValue(count, 1); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/class/async-method-static/returns-async-function-returns-arguments-from-own-function.js b/js/src/tests/test262/language/expressions/class/async-method-static/returns-async-function-returns-arguments-from-own-function.js new file mode 100644 index 0000000000..50c0bba57b --- /dev/null +++ b/js/src/tests/test262/language/expressions/class/async-method-static/returns-async-function-returns-arguments-from-own-function.js @@ -0,0 +1,41 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-functions/returns-async-function-returns-arguments-from-own-function.case +// - src/async-functions/evaluation/async-class-expr-static-method.template +/*--- +description: Async function returns an async function. (Static async method as a ClassExpression element) +esid: prod-AsyncMethod +features: [async-functions] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + +---*/ +let count = 0; + + +var C = class { + static async method(x) { + let a = arguments; + return async function() { return a === arguments; }; + } +}; +// Stores a reference `asyncFn` for case evaluation +let asyncFn = C.method; + +asyncFn(1).then(retFn => { + count++; + return retFn(); +}).then(result => { + assert.sameValue(result, false); + assert.sameValue(count, 1); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/class/async-method-static/returns-async-function-returns-newtarget.js b/js/src/tests/test262/language/expressions/class/async-method-static/returns-async-function-returns-newtarget.js new file mode 100644 index 0000000000..dc0d0bbc0b --- /dev/null +++ b/js/src/tests/test262/language/expressions/class/async-method-static/returns-async-function-returns-newtarget.js @@ -0,0 +1,40 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-functions/returns-async-function-returns-newtarget.case +// - src/async-functions/evaluation/async-class-expr-static-method.template +/*--- +description: Async function returns an async function. (Static async method as a ClassExpression element) +esid: prod-AsyncMethod +features: [async-functions] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + +---*/ +let count = 0; + + +var C = class { + static async method(x) { + return async function() { return new.target; }; + } +}; +// Stores a reference `asyncFn` for case evaluation +let asyncFn = C.method; + +asyncFn(1).then(retFn => { + count++; + return retFn(); +}).then(result => { + assert.sameValue(result, undefined); + assert.sameValue(count, 1); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/class/async-method-static/returns-async-function.js b/js/src/tests/test262/language/expressions/class/async-method-static/returns-async-function.js new file mode 100644 index 0000000000..f33b386a7a --- /dev/null +++ b/js/src/tests/test262/language/expressions/class/async-method-static/returns-async-function.js @@ -0,0 +1,40 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-functions/returns-async-function.case +// - src/async-functions/evaluation/async-class-expr-static-method.template +/*--- +description: Async function returns an async function. (Static async method as a ClassExpression element) +esid: prod-AsyncMethod +features: [async-functions] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + +---*/ +let count = 0; + + +var C = class { + static async method(x) { + return async function() { return x; }; + } +}; +// Stores a reference `asyncFn` for case evaluation +let asyncFn = C.method; + +asyncFn(1).then(retFn => { + count++; + return retFn(); +}).then(result => { + assert.sameValue(result, 1); + assert.sameValue(count, 1); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/class/async-method-static/shell.js b/js/src/tests/test262/language/expressions/class/async-method-static/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/class/async-method-static/shell.js |