diff --git a/src/params/default/async-gen-func-decl.template b/src/params/default/async-gen-func-decl.template new file mode 100644 index 0000000000000000000000000000000000000000..ad18e33c2058f638f38a39c784a7c07fb07d5399 --- /dev/null +++ b/src/params/default/async-gen-func-decl.template @@ -0,0 +1,29 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/async-generator/params- +name: async generator function declaration +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] +flags: [async] +features: [async-iteration] +---*/ + +var callCount = 0; +// Stores a reference `ref` for case evaluation +async function* ref(/*{ params }*/) { + /*{ body }*/ + callCount = callCount + 1; +} + +ref(/*{ args }*/).next().then(() => { + assert.sameValue(callCount, 1, 'generator function invoked exactly once'); +}).then($DONE, $DONE); diff --git a/src/params/default/async-gen-func-expr.template b/src/params/default/async-gen-func-expr.template new file mode 100644 index 0000000000000000000000000000000000000000..bf472577229021df25236f20117ea6dfcd713d18 --- /dev/null +++ b/src/params/default/async-gen-func-expr.template @@ -0,0 +1,30 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/async-generator/params- +name: async generator function expression +esid: sec-asyncgenerator-definitions-evaluation +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] +flags: [async] +features: [async-iteration] +---*/ + +var callCount = 0; +// Stores a reference `ref` for case evaluation +var ref; +ref = async function*(/*{ params }*/) { + /*{ body }*/ + callCount = callCount + 1; +}; + +ref(/*{ args }*/).next().then(() => { + assert.sameValue(callCount, 1, 'generator function invoked exactly once'); +}).then($DONE, $DONE); diff --git a/src/params/default/async-gen-meth.template b/src/params/default/async-gen-meth.template new file mode 100644 index 0000000000000000000000000000000000000000..88531de653b351ef9ac3f46d351706f23067dbfd --- /dev/null +++ b/src/params/default/async-gen-meth.template @@ -0,0 +1,37 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/expressions/object/method-definition/params-async-gen-meth- +name: async generator method +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +info: | + 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). + [...] +flags: [async] +features: [async-iteration] +---*/ + +var callCount = 0; +var obj = { + async *method(/*{ params }*/) { + /*{ body }*/ + callCount = callCount + 1; + } +}; + +// Stores a reference `ref` for case evaluation +var ref = obj.method; + +ref(/*{ args }*/).next().then(() => { + assert.sameValue(callCount, 1, 'generator method invoked exactly once'); +}).then($DONE, $DONE); diff --git a/src/params/default/async-gen-named-func-expr.template b/src/params/default/async-gen-named-func-expr.template new file mode 100644 index 0000000000000000000000000000000000000000..4d8aa531e6224efdbeb88f5e727f93cdf7aaf4cf --- /dev/null +++ b/src/params/default/async-gen-named-func-expr.template @@ -0,0 +1,30 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/async-generator/params-named- +name: async generator named function expression +esid: sec-asyncgenerator-definitions-evaluation +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] +flags: [async] +features: [async-iteration] +---*/ + +var callCount = 0; +// Stores a reference `ref` for case evaluation +var ref; +ref = async function* g(/*{ params }*/) { + /*{ body }*/ + callCount = callCount + 1; +}; + +ref(/*{ args }*/).next().then(() => { + assert.sameValue(callCount, 1, 'generator function invoked exactly once'); +}).then($DONE, $DONE); diff --git a/src/params/default/cls-decl-async-gen-meth-static.template b/src/params/default/cls-decl-async-gen-meth-static.template new file mode 100644 index 0000000000000000000000000000000000000000..896c1a4d0bc7c28b4530ff5845dbf58a43bcbac9 --- /dev/null +++ b/src/params/default/cls-decl-async-gen-meth-static.template @@ -0,0 +1,56 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/class/params-async-gen-meth-static- +name: static class expression generator method +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +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). + [...] +flags: [async] +features: [async-iteration] +---*/ + +var callCount = 0; +class C { + static async *method(/*{ params }*/) { + /*{ body }*/ + callCount = callCount + 1; + } +} + +// Stores a reference `ref` for case evaluation +var ref = C.method; + +ref(/*{ args }*/).next().then(() => { + assert.sameValue(callCount, 1, 'method invoked exactly once'); +}).then($DONE, $DONE); diff --git a/src/params/default/cls-decl-async-gen-meth.template b/src/params/default/cls-decl-async-gen-meth.template new file mode 100644 index 0000000000000000000000000000000000000000..045c679440480ae78ae9f385a6b9ee84398f7f9e --- /dev/null +++ b/src/params/default/cls-decl-async-gen-meth.template @@ -0,0 +1,55 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/class/params-async-gen-meth- +name: class expression method +esid: sec-class-definitions-runtime-semantics-evaluation +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 + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto 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). + [...] +flags: [async] +features: [async-iteration] +---*/ + +var callCount = 0; +class C { + async *method(/*{ params }*/) { + /*{ body }*/ + callCount = callCount + 1; + } +} + +// Stores a reference `ref` for case evaluation +var ref = C.prototype.method; + +ref(/*{ args }*/).next().then(() => { + assert.sameValue(callCount, 1, 'method invoked exactly once'); +}).then($DONE, $DONE); diff --git a/src/params/default/cls-expr-async-gen-meth-static.template b/src/params/default/cls-expr-async-gen-meth-static.template new file mode 100644 index 0000000000000000000000000000000000000000..345191dd4405fa0ac834008133fcd49eeb6a65eb --- /dev/null +++ b/src/params/default/cls-expr-async-gen-meth-static.template @@ -0,0 +1,56 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/expressions/class/params-async-gen-meth-static- +name: static class expression async generator method +esid: sec-class-definitions-runtime-semantics-evaluation +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 + + 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). + [...] +flags: [async] +features: [async-iteration] +---*/ + +var callCount = 0; +var C = class { + static async *method(/*{ params }*/) { + /*{ body }*/ + callCount = callCount + 1; + } +} + +// Stores a reference `ref` for case evaluation +var ref = C.method; + +ref(/*{ args }*/).next().then(() => { + assert.sameValue(callCount, 1, 'method invoked exactly once'); +}).then($DONE, $DONE); diff --git a/src/params/default/cls-expr-async-gen-meth.template b/src/params/default/cls-expr-async-gen-meth.template new file mode 100644 index 0000000000000000000000000000000000000000..ca94df65a2ecc5494025d40426c782d5f1f3f8be --- /dev/null +++ b/src/params/default/cls-expr-async-gen-meth.template @@ -0,0 +1,57 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/expressions/class/params-async-gen-meth- +name: class expression async generator method +esid: sec-class-definitions-runtime-semantics-evaluation +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 + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto 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). + [...] +flags: [async] +features: [async-iteration] +---*/ + +var callCount = 0; +var C = class { + async *method(/*{ params }*/) { + /*{ body }*/ + callCount = callCount + 1; + } +} + +// Stores a reference `ref` for case evaluation +var ref = C.prototype.method; + +ref(/*{ args }*/).next().then(() => { + assert.sameValue(callCount, 1, 'method invoked exactly once'); +}).then($DONE, $DONE); + diff --git a/src/params/error/async-gen-func-decl.template b/src/params/error/async-gen-func-decl.template new file mode 100644 index 0000000000000000000000000000000000000000..913d2b61d8b5be776a8d1667156397e9af8aaa93 --- /dev/null +++ b/src/params/error/async-gen-func-decl.template @@ -0,0 +1,29 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/async-generator/params- +name: async generator function declaration +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] +features: [async-iteration] +---*/ + +var callCount = 0; +async function* f(/*{ params }*/) { + /*{ body }*/ + callCount = callCount + 1; +} + +assert.throws(/*{ error }*/, function() { + f(/*{ args }*/); +}); + +assert.sameValue(callCount, 0, 'generator function body not evaluated'); diff --git a/src/params/error/async-gen-func-expr.template b/src/params/error/async-gen-func-expr.template new file mode 100644 index 0000000000000000000000000000000000000000..2f2c9e44aa0959b94074f298478e62d30a5cc8d3 --- /dev/null +++ b/src/params/error/async-gen-func-expr.template @@ -0,0 +1,29 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/async-generator/params- +name: async generator function expression +esid: sec-asyncgenerator-definitions-evaluation +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] +features: [async-iteration] +---*/ + +var callCount = 0; +var f; +f = async function*(/*{ params }*/) { + /*{ body }*/ + callCount = callCount + 1; +}; + +assert.throws(/*{ error }*/, function() { + f(/*{ args }*/); +}); +assert.sameValue(callCount, 0, 'generator function body not evaluated'); diff --git a/src/params/error/async-gen-meth.template b/src/params/error/async-gen-meth.template new file mode 100644 index 0000000000000000000000000000000000000000..8fc908ea6594cb423f4c61639a0f95aa56360e0a --- /dev/null +++ b/src/params/error/async-gen-meth.template @@ -0,0 +1,34 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/expressions/object/method-definition/params-async-gen-meth- +name: async generator method +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +info: | + 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). + [...] +features: [async-iteration] +---*/ + +var callCount = 0; +var obj = { + async *method(/*{ params }*/) { + /*{ body }*/ + callCount = callCount + 1; + } +}; + +assert.throws(/*{ error }*/, function() { + obj.method(/*{ args }*/); +}); +assert.sameValue(callCount, 0, 'generator method body not evaluated'); diff --git a/src/params/error/async-gen-named-func-expr.template b/src/params/error/async-gen-named-func-expr.template new file mode 100644 index 0000000000000000000000000000000000000000..0237b9ae9245ada7081e60e6b4afd163b0e68191 --- /dev/null +++ b/src/params/error/async-gen-named-func-expr.template @@ -0,0 +1,30 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/async-generator/params-named- +name: async generator named function expression +esid: sec-asyncgenerator-definitions-evaluation +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] +flags: [async] +features: [async-iteration] +---*/ + +var callCount = 0; +var f; +f = async function* g(/*{ params }*/) { + /*{ body }*/ + callCount = callCount + 1; +}; + +assert.throws(/*{ error }*/, function() { + f(/*{ args }*/); +}); +assert.sameValue(callCount, 0, 'generator function body not evaluated'); diff --git a/src/params/error/cls-decl-async-gen-meth-static.template b/src/params/error/cls-decl-async-gen-meth-static.template new file mode 100644 index 0000000000000000000000000000000000000000..5c89cf028c4b4f8c2e0d98c1fdff9104b0c4f5f6 --- /dev/null +++ b/src/params/error/cls-decl-async-gen-meth-static.template @@ -0,0 +1,54 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/class/params-async-gen-meth-static- +name: static class expression generator method +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +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). + [...] +features: [async-iteration] +---*/ + +var callCount = 0; +class C { + static async *method(/*{ params }*/) { + /*{ body }*/ + callCount = callCount + 1; + } +} + +assert.throws(/*{ error }*/, function() { + C.method(/*{ args }*/); +}); + +assert.sameValue(callCount, 0, 'method body not evaluated'); diff --git a/src/params/error/cls-decl-async-gen-meth.template b/src/params/error/cls-decl-async-gen-meth.template new file mode 100644 index 0000000000000000000000000000000000000000..a8295f8df346f02b3d0095263306dc38d9d0b976 --- /dev/null +++ b/src/params/error/cls-decl-async-gen-meth.template @@ -0,0 +1,52 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/class/params-async-gen-meth- +name: class expression method +esid: sec-class-definitions-runtime-semantics-evaluation +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 + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto 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). + [...] +features: [async-iteration] +---*/ + +var callCount = 0; +class C { + async *method(/*{ params }*/) { + /*{ body }*/ + callCount = callCount + 1; + } +} + +assert.throws(/*{ error }*/, function() { + C.prototype.method(/*{ args }*/); +}); +assert.sameValue(callCount, 0, 'method body not evaluated'); diff --git a/src/params/error/cls-expr-async-gen-meth-static.template b/src/params/error/cls-expr-async-gen-meth-static.template new file mode 100644 index 0000000000000000000000000000000000000000..c01742a081d575aedbd3894a74b5e99fb70e8118 --- /dev/null +++ b/src/params/error/cls-expr-async-gen-meth-static.template @@ -0,0 +1,53 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/expressions/class/params-async-gen-meth-static- +name: static class expression async generator method +esid: sec-class-definitions-runtime-semantics-evaluation +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 + + 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). + [...] +features: [async-iteration] +---*/ + +var callCount = 0; +var C = class { + static async *method(/*{ params }*/) { + /*{ body }*/ + callCount = callCount + 1; + } +}; + +assert.throws(/*{ error }*/, function() { + C.method(/*{ args }*/); +}); +assert.sameValue(callCount, 0, 'method body not evaluated'); diff --git a/src/params/error/cls-expr-async-gen-meth.template b/src/params/error/cls-expr-async-gen-meth.template new file mode 100644 index 0000000000000000000000000000000000000000..2f8735d2895f65438e12e526092c0a3baf10a352 --- /dev/null +++ b/src/params/error/cls-expr-async-gen-meth.template @@ -0,0 +1,74 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/expressions/class/params-async-gen-meth- +name: class expression async generator method +esid: sec-class-definitions-runtime-semantics-evaluation +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 + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod 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 GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +features: [async-iteration] +---*/ + +var callCount = 0; +var C = class { + async *method(/*{ params }*/) { + /*{ body }*/ + callCount = callCount + 1; + } +}; + +assert.throws(/*{ error }*/, function() { + C.prototype.method(/*{ args }*/); +}); +assert.sameValue(callCount, 0, 'method body not evaluated'); diff --git a/src/params/syntax/async-gen-func-decl.template b/src/params/syntax/async-gen-func-decl.template new file mode 100644 index 0000000000000000000000000000000000000000..905c4a9a8792609d59446ec6eef13994b3d8497d --- /dev/null +++ b/src/params/syntax/async-gen-func-decl.template @@ -0,0 +1,21 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/async-generator/params- +name: async generator function declaration +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] +features: [async-iteration] +---*/ + +async function* f(/*{ params }*/) { + /*{ body }*/ +} diff --git a/src/params/syntax/async-gen-func-expr.template b/src/params/syntax/async-gen-func-expr.template new file mode 100644 index 0000000000000000000000000000000000000000..681ca487202fe0545588c9b64548042573efcd53 --- /dev/null +++ b/src/params/syntax/async-gen-func-expr.template @@ -0,0 +1,21 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/async-generator/params- +name: async generator function expression +esid: sec-asyncgenerator-definitions-evaluation +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] +features: [async-iteration] +---*/ + +0, async function*(/*{ params }*/) { + /*{ body }*/ +}; diff --git a/src/params/syntax/async-gen-meth.template b/src/params/syntax/async-gen-meth.template new file mode 100644 index 0000000000000000000000000000000000000000..fbec15467c57f667b0397342b755bf54136e7ecf --- /dev/null +++ b/src/params/syntax/async-gen-meth.template @@ -0,0 +1,27 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/expressions/object/method-definition/params-async-gen-meth- +name: async generator method +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +info: | + 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). + [...] +features: [async-iteration] +---*/ + +0, { + async *method(/*{ params }*/) { + /*{ body }*/ + } +}; diff --git a/src/params/syntax/async-gen-named-func-expr.template b/src/params/syntax/async-gen-named-func-expr.template new file mode 100644 index 0000000000000000000000000000000000000000..0fbde5d22f0b7bc071dd9e6d068e0c86e29a5e70 --- /dev/null +++ b/src/params/syntax/async-gen-named-func-expr.template @@ -0,0 +1,22 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/async-generator/params-named- +name: async generator named function expression +esid: sec-asyncgenerator-definitions-evaluation +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] +flags: [async] +features: [async-iteration] +---*/ + +0, async function* g(/*{ params }*/) { + /*{ body }*/ +}; diff --git a/src/params/syntax/cls-decl-async-gen-meth-static.template b/src/params/syntax/cls-decl-async-gen-meth-static.template new file mode 100644 index 0000000000000000000000000000000000000000..ecd372f7a7cf2cb962596fb5f18ff57bcd2f6e35 --- /dev/null +++ b/src/params/syntax/cls-decl-async-gen-meth-static.template @@ -0,0 +1,46 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/class/params-async-gen-meth-static- +name: static class expression generator method +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +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). + [...] +features: [async-iteration] +---*/ + +class C { + static async *method(/*{ params }*/) { + /*{ body }*/ + } +} diff --git a/src/params/syntax/cls-decl-async-gen-meth.template b/src/params/syntax/cls-decl-async-gen-meth.template new file mode 100644 index 0000000000000000000000000000000000000000..20f4527e0a39aca4c29c0adcdc4bfcc8b02066d7 --- /dev/null +++ b/src/params/syntax/cls-decl-async-gen-meth.template @@ -0,0 +1,45 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/class/params-async-gen-meth- +name: class expression method +esid: sec-class-definitions-runtime-semantics-evaluation +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 + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto 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). + [...] +features: [async-iteration] +---*/ + +class C { + async *method(/*{ params }*/) { + /*{ body }*/ + } +} diff --git a/src/params/syntax/cls-expr-async-gen-meth-static.template b/src/params/syntax/cls-expr-async-gen-meth-static.template new file mode 100644 index 0000000000000000000000000000000000000000..25c81044a01823e6a3a1ba5ff6c8bcf095404124 --- /dev/null +++ b/src/params/syntax/cls-expr-async-gen-meth-static.template @@ -0,0 +1,46 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/expressions/class/params-async-gen-meth-static- +name: static class expression async generator method +esid: sec-class-definitions-runtime-semantics-evaluation +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 + + 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). + [...] +features: [async-iteration] +---*/ + +0, class { + static async *method(/*{ params }*/) { + /*{ body }*/ + } +}; diff --git a/src/params/syntax/cls-expr-async-gen-meth.template b/src/params/syntax/cls-expr-async-gen-meth.template new file mode 100644 index 0000000000000000000000000000000000000000..c3ca6b5131820bb675b4a96a3a0125ddacf9e9dc --- /dev/null +++ b/src/params/syntax/cls-expr-async-gen-meth.template @@ -0,0 +1,46 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/expressions/class/params-async-gen-meth- +name: class expression async generator method +esid: sec-class-definitions-runtime-semantics-evaluation +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 + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto 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). + [...] +features: [async-iteration] +---*/ + +0, class { + async *method(/*{ params }*/) { + /*{ body }*/ + } +}; diff --git a/test/language/expressions/async-generator/params-dflt-abrupt.js b/test/language/expressions/async-generator/params-dflt-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..644cdce6e0f35b6e443951dad9f5b8b38638e4ab --- /dev/null +++ b/test/language/expressions/async-generator/params-dflt-abrupt.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/params/dflt-abrupt.case +// - src/params/error/async-gen-func-expr.template +/*--- +description: Abrupt completion returned by evaluation of initializer (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [default-parameters, async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. + +---*/ + + +var callCount = 0; +var f; +f = async function*(_ = (function() { throw new Test262Error(); }())) { + + callCount = callCount + 1; +}; + +assert.throws(Test262Error, function() { + f(); +}); +assert.sameValue(callCount, 0, 'generator function body not evaluated'); diff --git a/test/language/expressions/async-generator/params-dflt-arg-val-not-undefined.js b/test/language/expressions/async-generator/params-dflt-arg-val-not-undefined.js new file mode 100644 index 0000000000000000000000000000000000000000..28c385083ed43f01239296ac9e04befcbc5b9da4 --- /dev/null +++ b/test/language/expressions/async-generator/params-dflt-arg-val-not-undefined.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/params/dflt-arg-val-not-undefined.case +// - src/params/default/async-gen-func-expr.template +/*--- +description: Use of intializer when argument value is not `undefined` (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [default-parameters, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + [...] + 23. Let iteratorRecord be Record {[[Iterator]]: + CreateListIterator(argumentsList), [[Done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + a. Perform ? IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + +---*/ +var obj = {}; +var falseCount = 0; +var stringCount = 0; +var nanCount = 0; +var zeroCount = 0; +var nullCount = 0; +var objCount = 0; + + +var callCount = 0; +// Stores a reference `ref` for case evaluation +var ref; +ref = async function*(aFalse = falseCount +=1, aString = stringCount += 1, aNaN = nanCount += 1, a0 = zeroCount += 1, aNull = nullCount += 1, aObj = objCount +=1) { + assert.sameValue(aFalse, false); + assert.sameValue(aString, ''); + assert.sameValue(aNaN, NaN); + assert.sameValue(a0, 0); + assert.sameValue(aNull, null); + assert.sameValue(aObj, obj); + callCount = callCount + 1; +}; + +ref(false, '', NaN, 0, null, obj).next().then(() => { + assert.sameValue(callCount, 1, 'generator function invoked exactly once'); +}).then($DONE, $DONE); + +assert.sameValue(falseCount, 0, 'initializer not evaluated: false'); +assert.sameValue(stringCount, 0, 'initializer not evaluated: string'); +assert.sameValue(nanCount, 0, 'initializer not evaluated: NaN'); +assert.sameValue(zeroCount, 0, 'initializer not evaluated: 0'); +assert.sameValue(nullCount, 0, 'initializer not evaluated: null'); +assert.sameValue(objCount, 0, 'initializer not evaluated: object'); diff --git a/test/language/expressions/async-generator/params-dflt-arg-val-undefined.js b/test/language/expressions/async-generator/params-dflt-arg-val-undefined.js new file mode 100644 index 0000000000000000000000000000000000000000..624160d65acf6f09999d35bf1d63f199814e731f --- /dev/null +++ b/test/language/expressions/async-generator/params-dflt-arg-val-undefined.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/params/dflt-arg-val-undefined.case +// - src/params/default/async-gen-func-expr.template +/*--- +description: Use of intializer when argument value is `undefined` (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [default-parameters, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + [...] + 23. Let iteratorRecord be Record {[[Iterator]]: + CreateListIterator(argumentsList), [[Done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + a. Perform ? IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + +---*/ + + +var callCount = 0; +// Stores a reference `ref` for case evaluation +var ref; +ref = async function*(fromLiteral = 23, fromExpr = 45, fromHole = 99) { + assert.sameValue(fromLiteral, 23); + assert.sameValue(fromExpr, 45); + assert.sameValue(fromHole, 99); + callCount = callCount + 1; +}; + +ref(undefined, void 0).next().then(() => { + assert.sameValue(callCount, 1, 'generator function invoked exactly once'); +}).then($DONE, $DONE); diff --git a/test/language/expressions/async-generator/params-dflt-duplicates.js b/test/language/expressions/async-generator/params-dflt-duplicates.js new file mode 100644 index 0000000000000000000000000000000000000000..745c94e254e67305d3fc81ee080ee2bf0f3dede4 --- /dev/null +++ b/test/language/expressions/async-generator/params-dflt-duplicates.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/params/dflt-duplicates.case +// - src/params/syntax/async-gen-func-expr.template +/*--- +description: It is a Syntax Error if BoundNames of FormalParameters contains any duplicate elements. (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [default-parameters, async-iteration] +flags: [generated] +negative: + phase: early + type: SyntaxError +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 14.1.2 Static Semantics: Early Errors + + StrictFormalParameters : FormalParameters + + - It is a Syntax Error if BoundNames of FormalParameters contains any + duplicate elements. + + FormalParameters : FormalParameterList + + - It is a Syntax Error if IsSimpleParameterList of FormalParameterList is + false and BoundNames of FormalParameterList contains any duplicate + elements. + +---*/ + + +0, async function*(x = 0, x) { + +}; diff --git a/test/language/expressions/async-generator/params-dflt-ref-later.js b/test/language/expressions/async-generator/params-dflt-ref-later.js new file mode 100644 index 0000000000000000000000000000000000000000..c3d810701d788340f97ff0a9b24919c8495a8c5d --- /dev/null +++ b/test/language/expressions/async-generator/params-dflt-ref-later.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/params/dflt-ref-later.case +// - src/params/error/async-gen-func-expr.template +/*--- +description: Referencing a parameter that occurs later in the ParameterList (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [default-parameters, async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. + +---*/ +var x = 0; + + +var callCount = 0; +var f; +f = async function*(x = y, y) { + + callCount = callCount + 1; +}; + +assert.throws(ReferenceError, function() { + f(); +}); +assert.sameValue(callCount, 0, 'generator function body not evaluated'); diff --git a/test/language/expressions/async-generator/params-dflt-ref-prior.js b/test/language/expressions/async-generator/params-dflt-ref-prior.js new file mode 100644 index 0000000000000000000000000000000000000000..04e4f2c7227934cd9972994596842d6ec48148a2 --- /dev/null +++ b/test/language/expressions/async-generator/params-dflt-ref-prior.js @@ -0,0 +1,45 @@ +// This file was procedurally generated from the following sources: +// - src/params/dflt-ref-prior.case +// - src/params/default/async-gen-func-expr.template +/*--- +description: Referencing a parameter that occurs earlier in the ParameterList (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [default-parameters, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. + +---*/ +var x = 0; + + +var callCount = 0; +// Stores a reference `ref` for case evaluation +var ref; +ref = async function*(x, y = x, z = y) { + assert.sameValue(x, 3, 'first argument value'); + assert.sameValue(y, 3, 'second argument value'); + assert.sameValue(z, 3, 'third argument value'); + callCount = callCount + 1; +}; + +ref(3).next().then(() => { + assert.sameValue(callCount, 1, 'generator function invoked exactly once'); +}).then($DONE, $DONE); diff --git a/test/language/expressions/async-generator/params-dflt-ref-self.js b/test/language/expressions/async-generator/params-dflt-ref-self.js new file mode 100644 index 0000000000000000000000000000000000000000..99a971be1e8a29d0c32315cce883f3b2d77c7fd8 --- /dev/null +++ b/test/language/expressions/async-generator/params-dflt-ref-self.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/params/dflt-ref-self.case +// - src/params/error/async-gen-func-expr.template +/*--- +description: Referencing a parameter from within its own initializer (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [default-parameters, async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. + +---*/ +var x = 0; + + +var callCount = 0; +var f; +f = async function*(x = x) { + + callCount = callCount + 1; +}; + +assert.throws(ReferenceError, function() { + f(); +}); +assert.sameValue(callCount, 0, 'generator function body not evaluated'); diff --git a/test/language/expressions/async-generator/params-dflt-rest.js b/test/language/expressions/async-generator/params-dflt-rest.js new file mode 100644 index 0000000000000000000000000000000000000000..5ff97c42135bb69e478db720e5a6199e71b4f77c --- /dev/null +++ b/test/language/expressions/async-generator/params-dflt-rest.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/params/dflt-rest.case +// - src/params/syntax/async-gen-func-expr.template +/*--- +description: RestParameter does not support an initializer (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [default-parameters, async-iteration] +flags: [generated] +negative: + phase: early + type: SyntaxError +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 14.1 Function Definitions + + Syntax + + FunctionRestParameter[Yield] : + + BindingRestElement[?Yield] + + 13.3.3 Destructuring Binding Patterns + + Syntax + + BindingRestElement[Yield] : + + ...BindingIdentifier[?Yield] + ...BindingPattern[?Yield] + +---*/ + + +0, async function*(...x = []) { + +}; diff --git a/test/language/expressions/async-generator/params-named-dflt-abrupt.js b/test/language/expressions/async-generator/params-named-dflt-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..4ffc0f0253bd91585654dfb7906505ea39612755 --- /dev/null +++ b/test/language/expressions/async-generator/params-named-dflt-abrupt.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/params/dflt-abrupt.case +// - src/params/error/async-gen-named-func-expr.template +/*--- +description: Abrupt completion returned by evaluation of initializer (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [default-parameters, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. + +---*/ + + +var callCount = 0; +var f; +f = async function* g(_ = (function() { throw new Test262Error(); }())) { + + callCount = callCount + 1; +}; + +assert.throws(Test262Error, function() { + f(); +}); +assert.sameValue(callCount, 0, 'generator function body not evaluated'); diff --git a/test/language/expressions/async-generator/params-named-dflt-arg-val-not-undefined.js b/test/language/expressions/async-generator/params-named-dflt-arg-val-not-undefined.js new file mode 100644 index 0000000000000000000000000000000000000000..608673ab905eaca9998a5046b47d0403d5dbf88b --- /dev/null +++ b/test/language/expressions/async-generator/params-named-dflt-arg-val-not-undefined.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/params/dflt-arg-val-not-undefined.case +// - src/params/default/async-gen-named-func-expr.template +/*--- +description: Use of intializer when argument value is not `undefined` (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [default-parameters, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + [...] + 23. Let iteratorRecord be Record {[[Iterator]]: + CreateListIterator(argumentsList), [[Done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + a. Perform ? IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + +---*/ +var obj = {}; +var falseCount = 0; +var stringCount = 0; +var nanCount = 0; +var zeroCount = 0; +var nullCount = 0; +var objCount = 0; + + +var callCount = 0; +// Stores a reference `ref` for case evaluation +var ref; +ref = async function* g(aFalse = falseCount +=1, aString = stringCount += 1, aNaN = nanCount += 1, a0 = zeroCount += 1, aNull = nullCount += 1, aObj = objCount +=1) { + assert.sameValue(aFalse, false); + assert.sameValue(aString, ''); + assert.sameValue(aNaN, NaN); + assert.sameValue(a0, 0); + assert.sameValue(aNull, null); + assert.sameValue(aObj, obj); + callCount = callCount + 1; +}; + +ref(false, '', NaN, 0, null, obj).next().then(() => { + assert.sameValue(callCount, 1, 'generator function invoked exactly once'); +}).then($DONE, $DONE); + +assert.sameValue(falseCount, 0, 'initializer not evaluated: false'); +assert.sameValue(stringCount, 0, 'initializer not evaluated: string'); +assert.sameValue(nanCount, 0, 'initializer not evaluated: NaN'); +assert.sameValue(zeroCount, 0, 'initializer not evaluated: 0'); +assert.sameValue(nullCount, 0, 'initializer not evaluated: null'); +assert.sameValue(objCount, 0, 'initializer not evaluated: object'); diff --git a/test/language/expressions/async-generator/params-named-dflt-arg-val-undefined.js b/test/language/expressions/async-generator/params-named-dflt-arg-val-undefined.js new file mode 100644 index 0000000000000000000000000000000000000000..22789874fd67d441eed63d03b0270c48e8b92abd --- /dev/null +++ b/test/language/expressions/async-generator/params-named-dflt-arg-val-undefined.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/params/dflt-arg-val-undefined.case +// - src/params/default/async-gen-named-func-expr.template +/*--- +description: Use of intializer when argument value is `undefined` (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [default-parameters, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + [...] + 23. Let iteratorRecord be Record {[[Iterator]]: + CreateListIterator(argumentsList), [[Done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + a. Perform ? IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + +---*/ + + +var callCount = 0; +// Stores a reference `ref` for case evaluation +var ref; +ref = async function* g(fromLiteral = 23, fromExpr = 45, fromHole = 99) { + assert.sameValue(fromLiteral, 23); + assert.sameValue(fromExpr, 45); + assert.sameValue(fromHole, 99); + callCount = callCount + 1; +}; + +ref(undefined, void 0).next().then(() => { + assert.sameValue(callCount, 1, 'generator function invoked exactly once'); +}).then($DONE, $DONE); diff --git a/test/language/expressions/async-generator/params-named-dflt-duplicates.js b/test/language/expressions/async-generator/params-named-dflt-duplicates.js new file mode 100644 index 0000000000000000000000000000000000000000..ab19b7c6b5a08daa39f91d9e26e6f32162e95e0d --- /dev/null +++ b/test/language/expressions/async-generator/params-named-dflt-duplicates.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/params/dflt-duplicates.case +// - src/params/syntax/async-gen-named-func-expr.template +/*--- +description: It is a Syntax Error if BoundNames of FormalParameters contains any duplicate elements. (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [default-parameters, async-iteration] +flags: [generated, async] +negative: + phase: early + type: SyntaxError +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + + 14.1.2 Static Semantics: Early Errors + + StrictFormalParameters : FormalParameters + + - It is a Syntax Error if BoundNames of FormalParameters contains any + duplicate elements. + + FormalParameters : FormalParameterList + + - It is a Syntax Error if IsSimpleParameterList of FormalParameterList is + false and BoundNames of FormalParameterList contains any duplicate + elements. + +---*/ + + +0, async function* g(x = 0, x) { + +}; diff --git a/test/language/expressions/async-generator/params-named-dflt-ref-later.js b/test/language/expressions/async-generator/params-named-dflt-ref-later.js new file mode 100644 index 0000000000000000000000000000000000000000..54919c33d844b0b12b4ec9222bda6dc4ed5d5ef0 --- /dev/null +++ b/test/language/expressions/async-generator/params-named-dflt-ref-later.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/params/dflt-ref-later.case +// - src/params/error/async-gen-named-func-expr.template +/*--- +description: Referencing a parameter that occurs later in the ParameterList (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [default-parameters, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. + +---*/ +var x = 0; + + +var callCount = 0; +var f; +f = async function* g(x = y, y) { + + callCount = callCount + 1; +}; + +assert.throws(ReferenceError, function() { + f(); +}); +assert.sameValue(callCount, 0, 'generator function body not evaluated'); diff --git a/test/language/expressions/async-generator/params-named-dflt-ref-prior.js b/test/language/expressions/async-generator/params-named-dflt-ref-prior.js new file mode 100644 index 0000000000000000000000000000000000000000..668346f84a159d2ae698148030a8c33f142d784d --- /dev/null +++ b/test/language/expressions/async-generator/params-named-dflt-ref-prior.js @@ -0,0 +1,45 @@ +// This file was procedurally generated from the following sources: +// - src/params/dflt-ref-prior.case +// - src/params/default/async-gen-named-func-expr.template +/*--- +description: Referencing a parameter that occurs earlier in the ParameterList (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [default-parameters, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. + +---*/ +var x = 0; + + +var callCount = 0; +// Stores a reference `ref` for case evaluation +var ref; +ref = async function* g(x, y = x, z = y) { + assert.sameValue(x, 3, 'first argument value'); + assert.sameValue(y, 3, 'second argument value'); + assert.sameValue(z, 3, 'third argument value'); + callCount = callCount + 1; +}; + +ref(3).next().then(() => { + assert.sameValue(callCount, 1, 'generator function invoked exactly once'); +}).then($DONE, $DONE); diff --git a/test/language/expressions/async-generator/params-named-dflt-ref-self.js b/test/language/expressions/async-generator/params-named-dflt-ref-self.js new file mode 100644 index 0000000000000000000000000000000000000000..481030f7e4b3de398b9140f06580a9f39b27f8b9 --- /dev/null +++ b/test/language/expressions/async-generator/params-named-dflt-ref-self.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/params/dflt-ref-self.case +// - src/params/error/async-gen-named-func-expr.template +/*--- +description: Referencing a parameter from within its own initializer (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [default-parameters, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. + +---*/ +var x = 0; + + +var callCount = 0; +var f; +f = async function* g(x = x) { + + callCount = callCount + 1; +}; + +assert.throws(ReferenceError, function() { + f(); +}); +assert.sameValue(callCount, 0, 'generator function body not evaluated'); diff --git a/test/language/expressions/async-generator/params-named-dflt-rest.js b/test/language/expressions/async-generator/params-named-dflt-rest.js new file mode 100644 index 0000000000000000000000000000000000000000..77783adfd1271e7d3e81f9ccbc18aedc69ba0285 --- /dev/null +++ b/test/language/expressions/async-generator/params-named-dflt-rest.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/params/dflt-rest.case +// - src/params/syntax/async-gen-named-func-expr.template +/*--- +description: RestParameter does not support an initializer (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [default-parameters, async-iteration] +flags: [generated, async] +negative: + phase: early + type: SyntaxError +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + + 14.1 Function Definitions + + Syntax + + FunctionRestParameter[Yield] : + + BindingRestElement[?Yield] + + 13.3.3 Destructuring Binding Patterns + + Syntax + + BindingRestElement[Yield] : + + ...BindingIdentifier[?Yield] + ...BindingPattern[?Yield] + +---*/ + + +0, async function* g(...x = []) { + +}; diff --git a/test/language/expressions/async-generator/params-named-trailing-comma-dflt-param.js b/test/language/expressions/async-generator/params-named-trailing-comma-dflt-param.js new file mode 100644 index 0000000000000000000000000000000000000000..602d72e7131e42032e19218f6cb737e7d1c1b552 --- /dev/null +++ b/test/language/expressions/async-generator/params-named-trailing-comma-dflt-param.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/params/trailing-comma-dflt-param.case +// - src/params/default/async-gen-named-func-expr.template +/*--- +description: A trailing comma should not increase the respective length, using default parameters (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + + Trailing comma in the parameters list + + 14.1 Function Definitions + + FormalParameters[Yield, Await] : FormalParameterList[?Yield, ?Await] , +---*/ + + +var callCount = 0; +// Stores a reference `ref` for case evaluation +var ref; +ref = async function* g(a, b = 39,) { + assert.sameValue(a, 42); + assert.sameValue(b, 39); + callCount = callCount + 1; +}; + +ref(42, undefined, 1).next().then(() => { + assert.sameValue(callCount, 1, 'generator function invoked exactly once'); +}).then($DONE, $DONE); + +assert.sameValue(ref.length, 1, 'length is properly set'); diff --git a/test/language/expressions/async-generator/params-named-trailing-comma-multiple-param.js b/test/language/expressions/async-generator/params-named-trailing-comma-multiple-param.js new file mode 100644 index 0000000000000000000000000000000000000000..f33913bce0b503f10c809cfcc7de738c17077977 --- /dev/null +++ b/test/language/expressions/async-generator/params-named-trailing-comma-multiple-param.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/params/trailing-comma-multiple-param.case +// - src/params/default/async-gen-named-func-expr.template +/*--- +description: A trailing comma should not increase the respective length, using multiple parameters (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + + Trailing comma in the parameters list + + 14.1 Function Definitions + + FormalParameters[Yield, Await] : FormalParameterList[?Yield, ?Await] , +---*/ + + +var callCount = 0; +// Stores a reference `ref` for case evaluation +var ref; +ref = async function* g(a, b,) { + assert.sameValue(a, 42); + assert.sameValue(b, 39); + callCount = callCount + 1; +}; + +ref(42, 39, 1).next().then(() => { + assert.sameValue(callCount, 1, 'generator function invoked exactly once'); +}).then($DONE, $DONE); + +assert.sameValue(ref.length, 2, 'length is properly set'); diff --git a/test/language/expressions/async-generator/params-named-trailing-comma-rest-early-error.js b/test/language/expressions/async-generator/params-named-trailing-comma-rest-early-error.js new file mode 100644 index 0000000000000000000000000000000000000000..83ea09a7a685edc3f1f46b73e54236da20c1b1b3 --- /dev/null +++ b/test/language/expressions/async-generator/params-named-trailing-comma-rest-early-error.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/params/trailing-comma-rest-early-error.case +// - src/params/syntax/async-gen-named-func-expr.template +/*--- +description: It's a syntax error if a FunctionRestParameter is followed by a trailing comma (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +negative: + phase: early + type: SyntaxError +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + + Trailing comma in the parameters list + + 14.1 Function Definitions + + FormalParameters[Yield, Await] : + [empty] + FunctionRestParameter[?Yield, ?Await] + FormalParameterList[?Yield, ?Await] + FormalParameterList[?Yield, ?Await] , + FormalParameterList[?Yield, ?Await] , FunctionRestParameter[?Yield, ?Await] +---*/ + + +0, async function* g(...a,) { + +}; diff --git a/test/language/expressions/async-generator/params-named-trailing-comma-single-param.js b/test/language/expressions/async-generator/params-named-trailing-comma-single-param.js new file mode 100644 index 0000000000000000000000000000000000000000..15265b64744a7a7f8177ddb0e12ddcb79a80eab4 --- /dev/null +++ b/test/language/expressions/async-generator/params-named-trailing-comma-single-param.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/params/trailing-comma-single-param.case +// - src/params/default/async-gen-named-func-expr.template +/*--- +description: A trailing comma should not increase the respective length, using a single parameter (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + + Trailing comma in the parameters list + + 14.1 Function Definitions + + FormalParameters[Yield, Await] : FormalParameterList[?Yield, ?Await] , +---*/ + + +var callCount = 0; +// Stores a reference `ref` for case evaluation +var ref; +ref = async function* g(a,) { + assert.sameValue(a, 42); + callCount = callCount + 1; +}; + +ref(42, 39).next().then(() => { + assert.sameValue(callCount, 1, 'generator function invoked exactly once'); +}).then($DONE, $DONE); + +assert.sameValue(ref.length, 1, 'length is properly set'); diff --git a/test/language/expressions/async-generator/params-trailing-comma-dflt-param.js b/test/language/expressions/async-generator/params-trailing-comma-dflt-param.js new file mode 100644 index 0000000000000000000000000000000000000000..e53a3d07161a28d97de3e011f98b7e083107a9ac --- /dev/null +++ b/test/language/expressions/async-generator/params-trailing-comma-dflt-param.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/params/trailing-comma-dflt-param.case +// - src/params/default/async-gen-func-expr.template +/*--- +description: A trailing comma should not increase the respective length, using default parameters (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + Trailing comma in the parameters list + + 14.1 Function Definitions + + FormalParameters[Yield, Await] : FormalParameterList[?Yield, ?Await] , +---*/ + + +var callCount = 0; +// Stores a reference `ref` for case evaluation +var ref; +ref = async function*(a, b = 39,) { + assert.sameValue(a, 42); + assert.sameValue(b, 39); + callCount = callCount + 1; +}; + +ref(42, undefined, 1).next().then(() => { + assert.sameValue(callCount, 1, 'generator function invoked exactly once'); +}).then($DONE, $DONE); + +assert.sameValue(ref.length, 1, 'length is properly set'); diff --git a/test/language/expressions/async-generator/params-trailing-comma-multiple-param.js b/test/language/expressions/async-generator/params-trailing-comma-multiple-param.js new file mode 100644 index 0000000000000000000000000000000000000000..c325742537989bbb78daee9b5e122f2b7b9fa653 --- /dev/null +++ b/test/language/expressions/async-generator/params-trailing-comma-multiple-param.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/params/trailing-comma-multiple-param.case +// - src/params/default/async-gen-func-expr.template +/*--- +description: A trailing comma should not increase the respective length, using multiple parameters (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + Trailing comma in the parameters list + + 14.1 Function Definitions + + FormalParameters[Yield, Await] : FormalParameterList[?Yield, ?Await] , +---*/ + + +var callCount = 0; +// Stores a reference `ref` for case evaluation +var ref; +ref = async function*(a, b,) { + assert.sameValue(a, 42); + assert.sameValue(b, 39); + callCount = callCount + 1; +}; + +ref(42, 39, 1).next().then(() => { + assert.sameValue(callCount, 1, 'generator function invoked exactly once'); +}).then($DONE, $DONE); + +assert.sameValue(ref.length, 2, 'length is properly set'); diff --git a/test/language/expressions/async-generator/params-trailing-comma-rest-early-error.js b/test/language/expressions/async-generator/params-trailing-comma-rest-early-error.js new file mode 100644 index 0000000000000000000000000000000000000000..3b8f40d3359503e9f7d866efa89a3aa24582ff07 --- /dev/null +++ b/test/language/expressions/async-generator/params-trailing-comma-rest-early-error.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/params/trailing-comma-rest-early-error.case +// - src/params/syntax/async-gen-func-expr.template +/*--- +description: It's a syntax error if a FunctionRestParameter is followed by a trailing comma (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +negative: + phase: early + type: SyntaxError +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + Trailing comma in the parameters list + + 14.1 Function Definitions + + FormalParameters[Yield, Await] : + [empty] + FunctionRestParameter[?Yield, ?Await] + FormalParameterList[?Yield, ?Await] + FormalParameterList[?Yield, ?Await] , + FormalParameterList[?Yield, ?Await] , FunctionRestParameter[?Yield, ?Await] +---*/ + + +0, async function*(...a,) { + +}; diff --git a/test/language/expressions/async-generator/params-trailing-comma-single-param.js b/test/language/expressions/async-generator/params-trailing-comma-single-param.js new file mode 100644 index 0000000000000000000000000000000000000000..af9b709eedee1440fcad6eff84fc481912c58610 --- /dev/null +++ b/test/language/expressions/async-generator/params-trailing-comma-single-param.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/params/trailing-comma-single-param.case +// - src/params/default/async-gen-func-expr.template +/*--- +description: A trailing comma should not increase the respective length, using a single parameter (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + Trailing comma in the parameters list + + 14.1 Function Definitions + + FormalParameters[Yield, Await] : FormalParameterList[?Yield, ?Await] , +---*/ + + +var callCount = 0; +// Stores a reference `ref` for case evaluation +var ref; +ref = async function*(a,) { + assert.sameValue(a, 42); + callCount = callCount + 1; +}; + +ref(42, 39).next().then(() => { + assert.sameValue(callCount, 1, 'generator function invoked exactly once'); +}).then($DONE, $DONE); + +assert.sameValue(ref.length, 1, 'length is properly set'); diff --git a/test/language/expressions/class/params-async-gen-meth-dflt-abrupt.js b/test/language/expressions/class/params-async-gen-meth-dflt-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..7122c9c52cfa5e32baeb263154aa7c465730fc5a --- /dev/null +++ b/test/language/expressions/class/params-async-gen-meth-dflt-abrupt.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/params/dflt-abrupt.case +// - src/params/error/cls-expr-async-gen-meth.template +/*--- +description: Abrupt completion returned by evaluation of initializer (class expression async generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [default-parameters, async-iteration] +flags: [generated] +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 + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod 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 GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + + 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 { + async *method(_ = (function() { throw new Test262Error(); }())) { + + callCount = callCount + 1; + } +}; + +assert.throws(Test262Error, function() { + C.prototype.method(); +}); +assert.sameValue(callCount, 0, 'method body not evaluated'); diff --git a/test/language/expressions/class/params-async-gen-meth-dflt-arg-val-not-undefined.js b/test/language/expressions/class/params-async-gen-meth-dflt-arg-val-not-undefined.js new file mode 100644 index 0000000000000000000000000000000000000000..665d7cbdb2f91d922adcb23ec1d597de90f990dc --- /dev/null +++ b/test/language/expressions/class/params-async-gen-meth-dflt-arg-val-not-undefined.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/params/dflt-arg-val-not-undefined.case +// - src/params/default/cls-expr-async-gen-meth.template +/*--- +description: Use of intializer when argument value is not `undefined` (class expression async generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [default-parameters, async-iteration] +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 + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto 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; +var C = class { + 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.prototype.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/test/language/expressions/class/params-async-gen-meth-dflt-arg-val-undefined.js b/test/language/expressions/class/params-async-gen-meth-dflt-arg-val-undefined.js new file mode 100644 index 0000000000000000000000000000000000000000..cdfc8994bfbd47077bea314e6699da62d012ea60 --- /dev/null +++ b/test/language/expressions/class/params-async-gen-meth-dflt-arg-val-undefined.js @@ -0,0 +1,75 @@ +// This file was procedurally generated from the following sources: +// - src/params/dflt-arg-val-undefined.case +// - src/params/default/cls-expr-async-gen-meth.template +/*--- +description: Use of intializer when argument value is `undefined` (class expression async generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [default-parameters, async-iteration] +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 + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto 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; +var C = class { + 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.prototype.method; + +ref(undefined, void 0).next().then(() => { + assert.sameValue(callCount, 1, 'method invoked exactly once'); +}).then($DONE, $DONE); + diff --git a/test/language/expressions/class/params-async-gen-meth-dflt-duplicates.js b/test/language/expressions/class/params-async-gen-meth-dflt-duplicates.js new file mode 100644 index 0000000000000000000000000000000000000000..3c5f065eb2bd580be88c7a713957e3c82f8327c4 --- /dev/null +++ b/test/language/expressions/class/params-async-gen-meth-dflt-duplicates.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/params/dflt-duplicates.case +// - src/params/syntax/cls-expr-async-gen-meth.template +/*--- +description: It is a Syntax Error if BoundNames of FormalParameters contains any duplicate elements. (class expression async generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [default-parameters, async-iteration] +flags: [generated] +negative: + phase: early + 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 + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto 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. + +---*/ + +0, class { + async *method(x = 0, x) { + + } +}; diff --git a/test/language/expressions/class/params-async-gen-meth-dflt-ref-later.js b/test/language/expressions/class/params-async-gen-meth-dflt-ref-later.js new file mode 100644 index 0000000000000000000000000000000000000000..ee0356ce441f623093bca17b1a62adc8b669fe8a --- /dev/null +++ b/test/language/expressions/class/params-async-gen-meth-dflt-ref-later.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/params/dflt-ref-later.case +// - src/params/error/cls-expr-async-gen-meth.template +/*--- +description: Referencing a parameter that occurs later in the ParameterList (class expression async generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [default-parameters, async-iteration] +flags: [generated] +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 + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod 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 GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + + 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 { + async *method(x = y, y) { + + callCount = callCount + 1; + } +}; + +assert.throws(ReferenceError, function() { + C.prototype.method(); +}); +assert.sameValue(callCount, 0, 'method body not evaluated'); diff --git a/test/language/expressions/class/params-async-gen-meth-dflt-ref-prior.js b/test/language/expressions/class/params-async-gen-meth-dflt-ref-prior.js new file mode 100644 index 0000000000000000000000000000000000000000..f1d724f9d3c42312a4bdd7e60612b13abe3b91e7 --- /dev/null +++ b/test/language/expressions/class/params-async-gen-meth-dflt-ref-prior.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/params/dflt-ref-prior.case +// - src/params/default/cls-expr-async-gen-meth.template +/*--- +description: Referencing a parameter that occurs earlier in the ParameterList (class expression async generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [default-parameters, async-iteration] +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 + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto 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; +var C = class { + 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.prototype.method; + +ref(3).next().then(() => { + assert.sameValue(callCount, 1, 'method invoked exactly once'); +}).then($DONE, $DONE); + diff --git a/test/language/expressions/class/params-async-gen-meth-dflt-ref-self.js b/test/language/expressions/class/params-async-gen-meth-dflt-ref-self.js new file mode 100644 index 0000000000000000000000000000000000000000..424deef887f4968ad84fb126f9647be0cf928942 --- /dev/null +++ b/test/language/expressions/class/params-async-gen-meth-dflt-ref-self.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/params/dflt-ref-self.case +// - src/params/error/cls-expr-async-gen-meth.template +/*--- +description: Referencing a parameter from within its own initializer (class expression async generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [default-parameters, async-iteration] +flags: [generated] +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 + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod 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 GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + + 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 { + async *method(x = x) { + + callCount = callCount + 1; + } +}; + +assert.throws(ReferenceError, function() { + C.prototype.method(); +}); +assert.sameValue(callCount, 0, 'method body not evaluated'); diff --git a/test/language/expressions/class/params-async-gen-meth-dflt-rest.js b/test/language/expressions/class/params-async-gen-meth-dflt-rest.js new file mode 100644 index 0000000000000000000000000000000000000000..2b9dcc31ed86468aa9c1c0d518f1d5b818135ff1 --- /dev/null +++ b/test/language/expressions/class/params-async-gen-meth-dflt-rest.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/params/dflt-rest.case +// - src/params/syntax/cls-expr-async-gen-meth.template +/*--- +description: RestParameter does not support an initializer (class expression async generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [default-parameters, async-iteration] +flags: [generated] +negative: + phase: early + 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 + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto 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] + +---*/ + +0, class { + async *method(...x = []) { + + } +}; diff --git a/test/language/expressions/class/params-async-gen-meth-static-dflt-abrupt.js b/test/language/expressions/class/params-async-gen-meth-static-dflt-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..6f31e8c0c38c9bc980da556d2e24b6ec17f4a0d4 --- /dev/null +++ b/test/language/expressions/class/params-async-gen-meth-static-dflt-abrupt.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/params/dflt-abrupt.case +// - src/params/error/cls-expr-async-gen-meth-static.template +/*--- +description: Abrupt completion returned by evaluation of initializer (static class expression async generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [default-parameters, async-iteration] +flags: [generated] +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 + + 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; +var C = class { + static async *method(_ = (function() { throw new Test262Error(); }())) { + + callCount = callCount + 1; + } +}; + +assert.throws(Test262Error, function() { + C.method(); +}); +assert.sameValue(callCount, 0, 'method body not evaluated'); diff --git a/test/language/expressions/class/params-async-gen-meth-static-dflt-arg-val-not-undefined.js b/test/language/expressions/class/params-async-gen-meth-static-dflt-arg-val-not-undefined.js new file mode 100644 index 0000000000000000000000000000000000000000..c26d1c825636ae813a7f004fdc73aca9f73d1070 --- /dev/null +++ b/test/language/expressions/class/params-async-gen-meth-static-dflt-arg-val-not-undefined.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/params/dflt-arg-val-not-undefined.case +// - src/params/default/cls-expr-async-gen-meth-static.template +/*--- +description: Use of intializer when argument value is not `undefined` (static class expression async generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [default-parameters, async-iteration] +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 + + 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; +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).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/test/language/expressions/class/params-async-gen-meth-static-dflt-arg-val-undefined.js b/test/language/expressions/class/params-async-gen-meth-static-dflt-arg-val-undefined.js new file mode 100644 index 0000000000000000000000000000000000000000..f216136fc50d4ac5c52020adc3965863026aad83 --- /dev/null +++ b/test/language/expressions/class/params-async-gen-meth-static-dflt-arg-val-undefined.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/params/dflt-arg-val-undefined.case +// - src/params/default/cls-expr-async-gen-meth-static.template +/*--- +description: Use of intializer when argument value is `undefined` (static class expression async generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [default-parameters, async-iteration] +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 + + 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; +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).next().then(() => { + assert.sameValue(callCount, 1, 'method invoked exactly once'); +}).then($DONE, $DONE); diff --git a/test/language/expressions/class/params-async-gen-meth-static-dflt-duplicates.js b/test/language/expressions/class/params-async-gen-meth-static-dflt-duplicates.js new file mode 100644 index 0000000000000000000000000000000000000000..20acf1b9eb8b62fb0d80e33994e0acce218ed998 --- /dev/null +++ b/test/language/expressions/class/params-async-gen-meth-static-dflt-duplicates.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/params/dflt-duplicates.case +// - src/params/syntax/cls-expr-async-gen-meth-static.template +/*--- +description: It is a Syntax Error if BoundNames of FormalParameters contains any duplicate elements. (static class expression async generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [default-parameters, async-iteration] +flags: [generated] +negative: + phase: early + 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 + + 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. + +---*/ + +0, class { + static async *method(x = 0, x) { + + } +}; diff --git a/test/language/expressions/class/params-async-gen-meth-static-dflt-ref-later.js b/test/language/expressions/class/params-async-gen-meth-static-dflt-ref-later.js new file mode 100644 index 0000000000000000000000000000000000000000..77eeca850215df90221441443683d2a83383ec43 --- /dev/null +++ b/test/language/expressions/class/params-async-gen-meth-static-dflt-ref-later.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/params/dflt-ref-later.case +// - src/params/error/cls-expr-async-gen-meth-static.template +/*--- +description: Referencing a parameter that occurs later in the ParameterList (static class expression async generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [default-parameters, async-iteration] +flags: [generated] +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 + + 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; +var C = class { + static async *method(x = y, y) { + + callCount = callCount + 1; + } +}; + +assert.throws(ReferenceError, function() { + C.method(); +}); +assert.sameValue(callCount, 0, 'method body not evaluated'); diff --git a/test/language/expressions/class/params-async-gen-meth-static-dflt-ref-prior.js b/test/language/expressions/class/params-async-gen-meth-static-dflt-ref-prior.js new file mode 100644 index 0000000000000000000000000000000000000000..c9a61d935ce343c79c6577a8fcdbc5458796278e --- /dev/null +++ b/test/language/expressions/class/params-async-gen-meth-static-dflt-ref-prior.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/params/dflt-ref-prior.case +// - src/params/default/cls-expr-async-gen-meth-static.template +/*--- +description: Referencing a parameter that occurs earlier in the ParameterList (static class expression async generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [default-parameters, async-iteration] +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 + + 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; +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).next().then(() => { + assert.sameValue(callCount, 1, 'method invoked exactly once'); +}).then($DONE, $DONE); diff --git a/test/language/expressions/class/params-async-gen-meth-static-dflt-ref-self.js b/test/language/expressions/class/params-async-gen-meth-static-dflt-ref-self.js new file mode 100644 index 0000000000000000000000000000000000000000..6f116fb083e05ac3831c5f1a04667ceae288e9ee --- /dev/null +++ b/test/language/expressions/class/params-async-gen-meth-static-dflt-ref-self.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/params/dflt-ref-self.case +// - src/params/error/cls-expr-async-gen-meth-static.template +/*--- +description: Referencing a parameter from within its own initializer (static class expression async generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [default-parameters, async-iteration] +flags: [generated] +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 + + 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; +var C = class { + static async *method(x = x) { + + callCount = callCount + 1; + } +}; + +assert.throws(ReferenceError, function() { + C.method(); +}); +assert.sameValue(callCount, 0, 'method body not evaluated'); diff --git a/test/language/expressions/class/params-async-gen-meth-static-dflt-rest.js b/test/language/expressions/class/params-async-gen-meth-static-dflt-rest.js new file mode 100644 index 0000000000000000000000000000000000000000..e54d23842368f14d6c1186547ac776d03a0fcdd1 --- /dev/null +++ b/test/language/expressions/class/params-async-gen-meth-static-dflt-rest.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/params/dflt-rest.case +// - src/params/syntax/cls-expr-async-gen-meth-static.template +/*--- +description: RestParameter does not support an initializer (static class expression async generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [default-parameters, async-iteration] +flags: [generated] +negative: + phase: early + 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 + + 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] + +---*/ + +0, class { + static async *method(...x = []) { + + } +}; diff --git a/test/language/expressions/class/params-async-gen-meth-static-trailing-comma-dflt-param.js b/test/language/expressions/class/params-async-gen-meth-static-trailing-comma-dflt-param.js new file mode 100644 index 0000000000000000000000000000000000000000..50d50b430e0a0c8672b24d81ee63b034289101d0 --- /dev/null +++ b/test/language/expressions/class/params-async-gen-meth-static-trailing-comma-dflt-param.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/params/trailing-comma-dflt-param.case +// - src/params/default/cls-expr-async-gen-meth-static.template +/*--- +description: A trailing comma should not increase the respective length, using default parameters (static class expression async generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +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 + + 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; +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).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/test/language/expressions/class/params-async-gen-meth-static-trailing-comma-multiple-param.js b/test/language/expressions/class/params-async-gen-meth-static-trailing-comma-multiple-param.js new file mode 100644 index 0000000000000000000000000000000000000000..84fb378d983e3e4d26939fe6857390bd0cc6b640 --- /dev/null +++ b/test/language/expressions/class/params-async-gen-meth-static-trailing-comma-multiple-param.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/params/trailing-comma-multiple-param.case +// - src/params/default/cls-expr-async-gen-meth-static.template +/*--- +description: A trailing comma should not increase the respective length, using multiple parameters (static class expression async generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +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 + + 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; +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).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/test/language/expressions/class/params-async-gen-meth-static-trailing-comma-rest-early-error.js b/test/language/expressions/class/params-async-gen-meth-static-trailing-comma-rest-early-error.js new file mode 100644 index 0000000000000000000000000000000000000000..9e58c0e5800297a46a788b5f76d26b91e27179a2 --- /dev/null +++ b/test/language/expressions/class/params-async-gen-meth-static-trailing-comma-rest-early-error.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/params/trailing-comma-rest-early-error.case +// - src/params/syntax/cls-expr-async-gen-meth-static.template +/*--- +description: It's a syntax error if a FunctionRestParameter is followed by a trailing comma (static class expression async generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated] +negative: + phase: early + 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 + + 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] +---*/ + +0, class { + static async *method(...a,) { + + } +}; diff --git a/test/language/expressions/class/params-async-gen-meth-static-trailing-comma-single-param.js b/test/language/expressions/class/params-async-gen-meth-static-trailing-comma-single-param.js new file mode 100644 index 0000000000000000000000000000000000000000..caa2600511bbf2cc5217eeb8f350b7bb72594ca4 --- /dev/null +++ b/test/language/expressions/class/params-async-gen-meth-static-trailing-comma-single-param.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/params/trailing-comma-single-param.case +// - src/params/default/cls-expr-async-gen-meth-static.template +/*--- +description: A trailing comma should not increase the respective length, using a single parameter (static class expression async generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +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 + + 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; +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).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/test/language/expressions/class/params-async-gen-meth-trailing-comma-dflt-param.js b/test/language/expressions/class/params-async-gen-meth-trailing-comma-dflt-param.js new file mode 100644 index 0000000000000000000000000000000000000000..669df9d070f0c5728b6689c5be1059ce5c3f1fcc --- /dev/null +++ b/test/language/expressions/class/params-async-gen-meth-trailing-comma-dflt-param.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/params/trailing-comma-dflt-param.case +// - src/params/default/cls-expr-async-gen-meth.template +/*--- +description: A trailing comma should not increase the respective length, using default parameters (class expression async generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +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 + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto 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; +var C = class { + 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.prototype.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/test/language/expressions/class/params-async-gen-meth-trailing-comma-multiple-param.js b/test/language/expressions/class/params-async-gen-meth-trailing-comma-multiple-param.js new file mode 100644 index 0000000000000000000000000000000000000000..e1d934b9914baf4372a85ee7bf4d76a812a5e9a5 --- /dev/null +++ b/test/language/expressions/class/params-async-gen-meth-trailing-comma-multiple-param.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/params/trailing-comma-multiple-param.case +// - src/params/default/cls-expr-async-gen-meth.template +/*--- +description: A trailing comma should not increase the respective length, using multiple parameters (class expression async generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +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 + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto 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; +var C = class { + 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.prototype.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/test/language/expressions/class/params-async-gen-meth-trailing-comma-rest-early-error.js b/test/language/expressions/class/params-async-gen-meth-trailing-comma-rest-early-error.js new file mode 100644 index 0000000000000000000000000000000000000000..122bd17adff402da6103ed53d6b43169e6294880 --- /dev/null +++ b/test/language/expressions/class/params-async-gen-meth-trailing-comma-rest-early-error.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/params/trailing-comma-rest-early-error.case +// - src/params/syntax/cls-expr-async-gen-meth.template +/*--- +description: It's a syntax error if a FunctionRestParameter is followed by a trailing comma (class expression async generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated] +negative: + phase: early + 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 + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto 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] +---*/ + +0, class { + async *method(...a,) { + + } +}; diff --git a/test/language/expressions/class/params-async-gen-meth-trailing-comma-single-param.js b/test/language/expressions/class/params-async-gen-meth-trailing-comma-single-param.js new file mode 100644 index 0000000000000000000000000000000000000000..4e930a0bbd271e7bf7a0bc167a2d0a10c755106b --- /dev/null +++ b/test/language/expressions/class/params-async-gen-meth-trailing-comma-single-param.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/params/trailing-comma-single-param.case +// - src/params/default/cls-expr-async-gen-meth.template +/*--- +description: A trailing comma should not increase the respective length, using a single parameter (class expression async generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +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 + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto 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; +var C = class { + async *method(a,) { + assert.sameValue(a, 42); + callCount = callCount + 1; + } +} + +// Stores a reference `ref` for case evaluation +var ref = C.prototype.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/test/language/expressions/object/method-definition/params-async-gen-meth-dflt-abrupt.js b/test/language/expressions/object/method-definition/params-async-gen-meth-dflt-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..2f6c0c554cd523fa3135dbec1788e3b3a8c85c4b --- /dev/null +++ b/test/language/expressions/object/method-definition/params-async-gen-meth-dflt-abrupt.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/params/dflt-abrupt.case +// - src/params/error/async-gen-meth.template +/*--- +description: Abrupt completion returned by evaluation of initializer (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [default-parameters, async-iteration] +flags: [generated] +info: | + 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; +var obj = { + async *method(_ = (function() { throw new Test262Error(); }())) { + + callCount = callCount + 1; + } +}; + +assert.throws(Test262Error, function() { + obj.method(); +}); +assert.sameValue(callCount, 0, 'generator method body not evaluated'); diff --git a/test/language/expressions/object/method-definition/params-async-gen-meth-dflt-arg-val-not-undefined.js b/test/language/expressions/object/method-definition/params-async-gen-meth-dflt-arg-val-not-undefined.js new file mode 100644 index 0000000000000000000000000000000000000000..9d3c7820d2b90e5871d24d9de6270db3662605da --- /dev/null +++ b/test/language/expressions/object/method-definition/params-async-gen-meth-dflt-arg-val-not-undefined.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/params/dflt-arg-val-not-undefined.case +// - src/params/default/async-gen-meth.template +/*--- +description: Use of intializer when argument value is not `undefined` (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [default-parameters, async-iteration] +flags: [generated, async] +info: | + 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; +var obj = { + 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 = obj.method; + +ref(false, '', NaN, 0, null, obj).next().then(() => { + assert.sameValue(callCount, 1, 'generator 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/test/language/expressions/object/method-definition/params-async-gen-meth-dflt-arg-val-undefined.js b/test/language/expressions/object/method-definition/params-async-gen-meth-dflt-arg-val-undefined.js new file mode 100644 index 0000000000000000000000000000000000000000..adef672abd6d294f66c0486ec4598754346326a5 --- /dev/null +++ b/test/language/expressions/object/method-definition/params-async-gen-meth-dflt-arg-val-undefined.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/params/dflt-arg-val-undefined.case +// - src/params/default/async-gen-meth.template +/*--- +description: Use of intializer when argument value is `undefined` (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [default-parameters, async-iteration] +flags: [generated, async] +info: | + 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; +var obj = { + 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 = obj.method; + +ref(undefined, void 0).next().then(() => { + assert.sameValue(callCount, 1, 'generator method invoked exactly once'); +}).then($DONE, $DONE); diff --git a/test/language/expressions/object/method-definition/params-async-gen-meth-dflt-duplicates.js b/test/language/expressions/object/method-definition/params-async-gen-meth-dflt-duplicates.js new file mode 100644 index 0000000000000000000000000000000000000000..9010b6ce3e9573c5cd9ddd5832e968171e79b020 --- /dev/null +++ b/test/language/expressions/object/method-definition/params-async-gen-meth-dflt-duplicates.js @@ -0,0 +1,46 @@ +// This file was procedurally generated from the following sources: +// - src/params/dflt-duplicates.case +// - src/params/syntax/async-gen-meth.template +/*--- +description: It is a Syntax Error if BoundNames of FormalParameters contains any duplicate elements. (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [default-parameters, async-iteration] +flags: [generated] +negative: + phase: early + type: SyntaxError +info: | + 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. + +---*/ + +0, { + async *method(x = 0, x) { + + } +}; diff --git a/test/language/expressions/object/method-definition/params-async-gen-meth-dflt-ref-later.js b/test/language/expressions/object/method-definition/params-async-gen-meth-dflt-ref-later.js new file mode 100644 index 0000000000000000000000000000000000000000..db8b2a53119c9d36a18478a2a050bf9182eeeb1f --- /dev/null +++ b/test/language/expressions/object/method-definition/params-async-gen-meth-dflt-ref-later.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/params/dflt-ref-later.case +// - src/params/error/async-gen-meth.template +/*--- +description: Referencing a parameter that occurs later in the ParameterList (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [default-parameters, async-iteration] +flags: [generated] +info: | + 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; +var obj = { + async *method(x = y, y) { + + callCount = callCount + 1; + } +}; + +assert.throws(ReferenceError, function() { + obj.method(); +}); +assert.sameValue(callCount, 0, 'generator method body not evaluated'); diff --git a/test/language/expressions/object/method-definition/params-async-gen-meth-dflt-ref-prior.js b/test/language/expressions/object/method-definition/params-async-gen-meth-dflt-ref-prior.js new file mode 100644 index 0000000000000000000000000000000000000000..3f0515f0bc935ed11754a022de3f579398c23668 --- /dev/null +++ b/test/language/expressions/object/method-definition/params-async-gen-meth-dflt-ref-prior.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/params/dflt-ref-prior.case +// - src/params/default/async-gen-meth.template +/*--- +description: Referencing a parameter that occurs earlier in the ParameterList (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [default-parameters, async-iteration] +flags: [generated, async] +info: | + 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; +var obj = { + 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 = obj.method; + +ref(3).next().then(() => { + assert.sameValue(callCount, 1, 'generator method invoked exactly once'); +}).then($DONE, $DONE); diff --git a/test/language/expressions/object/method-definition/params-async-gen-meth-dflt-ref-self.js b/test/language/expressions/object/method-definition/params-async-gen-meth-dflt-ref-self.js new file mode 100644 index 0000000000000000000000000000000000000000..0d218040446e00d9fdd759d0e3cc326edc22247f --- /dev/null +++ b/test/language/expressions/object/method-definition/params-async-gen-meth-dflt-ref-self.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/params/dflt-ref-self.case +// - src/params/error/async-gen-meth.template +/*--- +description: Referencing a parameter from within its own initializer (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [default-parameters, async-iteration] +flags: [generated] +info: | + 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; +var obj = { + async *method(x = x) { + + callCount = callCount + 1; + } +}; + +assert.throws(ReferenceError, function() { + obj.method(); +}); +assert.sameValue(callCount, 0, 'generator method body not evaluated'); diff --git a/test/language/expressions/object/method-definition/params-async-gen-meth-dflt-rest.js b/test/language/expressions/object/method-definition/params-async-gen-meth-dflt-rest.js new file mode 100644 index 0000000000000000000000000000000000000000..93c7750f93fbf186f8320788bbd7fa23207be2d1 --- /dev/null +++ b/test/language/expressions/object/method-definition/params-async-gen-meth-dflt-rest.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/params/dflt-rest.case +// - src/params/syntax/async-gen-meth.template +/*--- +description: RestParameter does not support an initializer (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [default-parameters, async-iteration] +flags: [generated] +negative: + phase: early + type: SyntaxError +info: | + 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] + +---*/ + +0, { + async *method(...x = []) { + + } +}; diff --git a/test/language/expressions/object/method-definition/params-async-gen-meth-trailing-comma-dflt-param.js b/test/language/expressions/object/method-definition/params-async-gen-meth-trailing-comma-dflt-param.js new file mode 100644 index 0000000000000000000000000000000000000000..1ec0d52e545dfcb5638af30e3ecfe08a2dd488dc --- /dev/null +++ b/test/language/expressions/object/method-definition/params-async-gen-meth-trailing-comma-dflt-param.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/params/trailing-comma-dflt-param.case +// - src/params/default/async-gen-meth.template +/*--- +description: A trailing comma should not increase the respective length, using default parameters (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + 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; +var obj = { + 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 = obj.method; + +ref(42, undefined, 1).next().then(() => { + assert.sameValue(callCount, 1, 'generator method invoked exactly once'); +}).then($DONE, $DONE); + +assert.sameValue(ref.length, 1, 'length is properly set'); diff --git a/test/language/expressions/object/method-definition/params-async-gen-meth-trailing-comma-multiple-param.js b/test/language/expressions/object/method-definition/params-async-gen-meth-trailing-comma-multiple-param.js new file mode 100644 index 0000000000000000000000000000000000000000..8a8cc5936078e7e4ed8fc0e72568680b6bc7d813 --- /dev/null +++ b/test/language/expressions/object/method-definition/params-async-gen-meth-trailing-comma-multiple-param.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/params/trailing-comma-multiple-param.case +// - src/params/default/async-gen-meth.template +/*--- +description: A trailing comma should not increase the respective length, using multiple parameters (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + 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; +var obj = { + async *method(a, b,) { + assert.sameValue(a, 42); + assert.sameValue(b, 39); + callCount = callCount + 1; + } +}; + +// Stores a reference `ref` for case evaluation +var ref = obj.method; + +ref(42, 39, 1).next().then(() => { + assert.sameValue(callCount, 1, 'generator method invoked exactly once'); +}).then($DONE, $DONE); + +assert.sameValue(ref.length, 2, 'length is properly set'); diff --git a/test/language/expressions/object/method-definition/params-async-gen-meth-trailing-comma-rest-early-error.js b/test/language/expressions/object/method-definition/params-async-gen-meth-trailing-comma-rest-early-error.js new file mode 100644 index 0000000000000000000000000000000000000000..096c7d9d5a83ba1beda1e6e9a3b285fe9f316516 --- /dev/null +++ b/test/language/expressions/object/method-definition/params-async-gen-meth-trailing-comma-rest-early-error.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/params/trailing-comma-rest-early-error.case +// - src/params/syntax/async-gen-meth.template +/*--- +description: It's a syntax error if a FunctionRestParameter is followed by a trailing comma (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated] +negative: + phase: early + type: SyntaxError +info: | + 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] +---*/ + +0, { + async *method(...a,) { + + } +}; diff --git a/test/language/expressions/object/method-definition/params-async-gen-meth-trailing-comma-single-param.js b/test/language/expressions/object/method-definition/params-async-gen-meth-trailing-comma-single-param.js new file mode 100644 index 0000000000000000000000000000000000000000..879a1534ddc2fbd4bc2237c62de170a1a4d272e1 --- /dev/null +++ b/test/language/expressions/object/method-definition/params-async-gen-meth-trailing-comma-single-param.js @@ -0,0 +1,46 @@ +// This file was procedurally generated from the following sources: +// - src/params/trailing-comma-single-param.case +// - src/params/default/async-gen-meth.template +/*--- +description: A trailing comma should not increase the respective length, using a single parameter (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + 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; +var obj = { + async *method(a,) { + assert.sameValue(a, 42); + callCount = callCount + 1; + } +}; + +// Stores a reference `ref` for case evaluation +var ref = obj.method; + +ref(42, 39).next().then(() => { + assert.sameValue(callCount, 1, 'generator method invoked exactly once'); +}).then($DONE, $DONE); + +assert.sameValue(ref.length, 1, 'length is properly set'); diff --git a/test/language/statements/async-generator/params-dflt-abrupt.js b/test/language/statements/async-generator/params-dflt-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..d9d5b14131762c2d2c94bc60325d381046d64058 --- /dev/null +++ b/test/language/statements/async-generator/params-dflt-abrupt.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/params/dflt-abrupt.case +// - src/params/error/async-gen-func-decl.template +/*--- +description: Abrupt completion returned by evaluation of initializer (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [default-parameters, async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. + +---*/ + + +var callCount = 0; +async function* f(_ = (function() { throw new Test262Error(); }())) { + + callCount = callCount + 1; +} + +assert.throws(Test262Error, function() { + f(); +}); + +assert.sameValue(callCount, 0, 'generator function body not evaluated'); diff --git a/test/language/statements/async-generator/params-dflt-arg-val-not-undefined.js b/test/language/statements/async-generator/params-dflt-arg-val-not-undefined.js new file mode 100644 index 0000000000000000000000000000000000000000..b3edd7fa37b9e0225f727772e0cf96cf6964f6b1 --- /dev/null +++ b/test/language/statements/async-generator/params-dflt-arg-val-not-undefined.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/params/dflt-arg-val-not-undefined.case +// - src/params/default/async-gen-func-decl.template +/*--- +description: Use of intializer when argument value is not `undefined` (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [default-parameters, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + [...] + 23. Let iteratorRecord be Record {[[Iterator]]: + CreateListIterator(argumentsList), [[Done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + a. Perform ? IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + +---*/ +var obj = {}; +var falseCount = 0; +var stringCount = 0; +var nanCount = 0; +var zeroCount = 0; +var nullCount = 0; +var objCount = 0; + + +var callCount = 0; +// Stores a reference `ref` for case evaluation +async function* ref(aFalse = falseCount +=1, aString = stringCount += 1, aNaN = nanCount += 1, a0 = zeroCount += 1, aNull = nullCount += 1, aObj = objCount +=1) { + assert.sameValue(aFalse, false); + assert.sameValue(aString, ''); + assert.sameValue(aNaN, NaN); + assert.sameValue(a0, 0); + assert.sameValue(aNull, null); + assert.sameValue(aObj, obj); + callCount = callCount + 1; +} + +ref(false, '', NaN, 0, null, obj).next().then(() => { + assert.sameValue(callCount, 1, 'generator function invoked exactly once'); +}).then($DONE, $DONE); + +assert.sameValue(falseCount, 0, 'initializer not evaluated: false'); +assert.sameValue(stringCount, 0, 'initializer not evaluated: string'); +assert.sameValue(nanCount, 0, 'initializer not evaluated: NaN'); +assert.sameValue(zeroCount, 0, 'initializer not evaluated: 0'); +assert.sameValue(nullCount, 0, 'initializer not evaluated: null'); +assert.sameValue(objCount, 0, 'initializer not evaluated: object'); diff --git a/test/language/statements/async-generator/params-dflt-arg-val-undefined.js b/test/language/statements/async-generator/params-dflt-arg-val-undefined.js new file mode 100644 index 0000000000000000000000000000000000000000..210f7ed02fe8c07a3ca1ae67e3e62384f65d2b0c --- /dev/null +++ b/test/language/statements/async-generator/params-dflt-arg-val-undefined.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/params/dflt-arg-val-undefined.case +// - src/params/default/async-gen-func-decl.template +/*--- +description: Use of intializer when argument value is `undefined` (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [default-parameters, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + [...] + 23. Let iteratorRecord be Record {[[Iterator]]: + CreateListIterator(argumentsList), [[Done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + a. Perform ? IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + +---*/ + + +var callCount = 0; +// Stores a reference `ref` for case evaluation +async function* ref(fromLiteral = 23, fromExpr = 45, fromHole = 99) { + assert.sameValue(fromLiteral, 23); + assert.sameValue(fromExpr, 45); + assert.sameValue(fromHole, 99); + callCount = callCount + 1; +} + +ref(undefined, void 0).next().then(() => { + assert.sameValue(callCount, 1, 'generator function invoked exactly once'); +}).then($DONE, $DONE); diff --git a/test/language/statements/async-generator/params-dflt-duplicates.js b/test/language/statements/async-generator/params-dflt-duplicates.js new file mode 100644 index 0000000000000000000000000000000000000000..c4ce7ec567d0dc48336c9e566a8f37c51301a994 --- /dev/null +++ b/test/language/statements/async-generator/params-dflt-duplicates.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/params/dflt-duplicates.case +// - src/params/syntax/async-gen-func-decl.template +/*--- +description: It is a Syntax Error if BoundNames of FormalParameters contains any duplicate elements. (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [default-parameters, async-iteration] +flags: [generated] +negative: + phase: early + type: SyntaxError +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 14.1.2 Static Semantics: Early Errors + + StrictFormalParameters : FormalParameters + + - It is a Syntax Error if BoundNames of FormalParameters contains any + duplicate elements. + + FormalParameters : FormalParameterList + + - It is a Syntax Error if IsSimpleParameterList of FormalParameterList is + false and BoundNames of FormalParameterList contains any duplicate + elements. + +---*/ + + +async function* f(x = 0, x) { + +} diff --git a/test/language/statements/async-generator/params-dflt-ref-later.js b/test/language/statements/async-generator/params-dflt-ref-later.js new file mode 100644 index 0000000000000000000000000000000000000000..0b784bd6d23ad057bf2ab68fdd1e27f11b24fbea --- /dev/null +++ b/test/language/statements/async-generator/params-dflt-ref-later.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/params/dflt-ref-later.case +// - src/params/error/async-gen-func-decl.template +/*--- +description: Referencing a parameter that occurs later in the ParameterList (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [default-parameters, async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. + +---*/ +var x = 0; + + +var callCount = 0; +async function* f(x = y, y) { + + callCount = callCount + 1; +} + +assert.throws(ReferenceError, function() { + f(); +}); + +assert.sameValue(callCount, 0, 'generator function body not evaluated'); diff --git a/test/language/statements/async-generator/params-dflt-ref-prior.js b/test/language/statements/async-generator/params-dflt-ref-prior.js new file mode 100644 index 0000000000000000000000000000000000000000..bd15783b963e6b366b8b28c4e21f0df05e74ba74 --- /dev/null +++ b/test/language/statements/async-generator/params-dflt-ref-prior.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/params/dflt-ref-prior.case +// - src/params/default/async-gen-func-decl.template +/*--- +description: Referencing a parameter that occurs earlier in the ParameterList (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [default-parameters, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. + +---*/ +var x = 0; + + +var callCount = 0; +// Stores a reference `ref` for case evaluation +async function* ref(x, y = x, z = y) { + assert.sameValue(x, 3, 'first argument value'); + assert.sameValue(y, 3, 'second argument value'); + assert.sameValue(z, 3, 'third argument value'); + callCount = callCount + 1; +} + +ref(3).next().then(() => { + assert.sameValue(callCount, 1, 'generator function invoked exactly once'); +}).then($DONE, $DONE); diff --git a/test/language/statements/async-generator/params-dflt-ref-self.js b/test/language/statements/async-generator/params-dflt-ref-self.js new file mode 100644 index 0000000000000000000000000000000000000000..593279c3ea073a82985406cdac03ee3106e84b15 --- /dev/null +++ b/test/language/statements/async-generator/params-dflt-ref-self.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/params/dflt-ref-self.case +// - src/params/error/async-gen-func-decl.template +/*--- +description: Referencing a parameter from within its own initializer (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [default-parameters, async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. + +---*/ +var x = 0; + + +var callCount = 0; +async function* f(x = x) { + + callCount = callCount + 1; +} + +assert.throws(ReferenceError, function() { + f(); +}); + +assert.sameValue(callCount, 0, 'generator function body not evaluated'); diff --git a/test/language/statements/async-generator/params-dflt-rest.js b/test/language/statements/async-generator/params-dflt-rest.js new file mode 100644 index 0000000000000000000000000000000000000000..ab7f2f509b2ce57bfa699bcd09f631da659fb338 --- /dev/null +++ b/test/language/statements/async-generator/params-dflt-rest.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/params/dflt-rest.case +// - src/params/syntax/async-gen-func-decl.template +/*--- +description: RestParameter does not support an initializer (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [default-parameters, async-iteration] +flags: [generated] +negative: + phase: early + type: SyntaxError +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + 14.1 Function Definitions + + Syntax + + FunctionRestParameter[Yield] : + + BindingRestElement[?Yield] + + 13.3.3 Destructuring Binding Patterns + + Syntax + + BindingRestElement[Yield] : + + ...BindingIdentifier[?Yield] + ...BindingPattern[?Yield] + +---*/ + + +async function* f(...x = []) { + +} diff --git a/test/language/statements/async-generator/params-trailing-comma-dflt-param.js b/test/language/statements/async-generator/params-trailing-comma-dflt-param.js new file mode 100644 index 0000000000000000000000000000000000000000..2dccdb9f19e323cfdf4193073ce07d13eb8c5dbc --- /dev/null +++ b/test/language/statements/async-generator/params-trailing-comma-dflt-param.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/params/trailing-comma-dflt-param.case +// - src/params/default/async-gen-func-decl.template +/*--- +description: A trailing comma should not increase the respective length, using default parameters (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + Trailing comma in the parameters list + + 14.1 Function Definitions + + FormalParameters[Yield, Await] : FormalParameterList[?Yield, ?Await] , +---*/ + + +var callCount = 0; +// Stores a reference `ref` for case evaluation +async function* ref(a, b = 39,) { + assert.sameValue(a, 42); + assert.sameValue(b, 39); + callCount = callCount + 1; +} + +ref(42, undefined, 1).next().then(() => { + assert.sameValue(callCount, 1, 'generator function invoked exactly once'); +}).then($DONE, $DONE); + +assert.sameValue(ref.length, 1, 'length is properly set'); diff --git a/test/language/statements/async-generator/params-trailing-comma-multiple-param.js b/test/language/statements/async-generator/params-trailing-comma-multiple-param.js new file mode 100644 index 0000000000000000000000000000000000000000..dee70cc77182d029c1c99de0daa2d8954b9dbfe3 --- /dev/null +++ b/test/language/statements/async-generator/params-trailing-comma-multiple-param.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/params/trailing-comma-multiple-param.case +// - src/params/default/async-gen-func-decl.template +/*--- +description: A trailing comma should not increase the respective length, using multiple parameters (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + Trailing comma in the parameters list + + 14.1 Function Definitions + + FormalParameters[Yield, Await] : FormalParameterList[?Yield, ?Await] , +---*/ + + +var callCount = 0; +// Stores a reference `ref` for case evaluation +async function* ref(a, b,) { + assert.sameValue(a, 42); + assert.sameValue(b, 39); + callCount = callCount + 1; +} + +ref(42, 39, 1).next().then(() => { + assert.sameValue(callCount, 1, 'generator function invoked exactly once'); +}).then($DONE, $DONE); + +assert.sameValue(ref.length, 2, 'length is properly set'); diff --git a/test/language/statements/async-generator/params-trailing-comma-rest-early-error.js b/test/language/statements/async-generator/params-trailing-comma-rest-early-error.js new file mode 100644 index 0000000000000000000000000000000000000000..34d07ebb8791019f0febaf12ec96088a17b89660 --- /dev/null +++ b/test/language/statements/async-generator/params-trailing-comma-rest-early-error.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/params/trailing-comma-rest-early-error.case +// - src/params/syntax/async-gen-func-decl.template +/*--- +description: It's a syntax error if a FunctionRestParameter is followed by a trailing comma (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +negative: + phase: early + type: SyntaxError +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + Trailing comma in the parameters list + + 14.1 Function Definitions + + FormalParameters[Yield, Await] : + [empty] + FunctionRestParameter[?Yield, ?Await] + FormalParameterList[?Yield, ?Await] + FormalParameterList[?Yield, ?Await] , + FormalParameterList[?Yield, ?Await] , FunctionRestParameter[?Yield, ?Await] +---*/ + + +async function* f(...a,) { + +} diff --git a/test/language/statements/async-generator/params-trailing-comma-single-param.js b/test/language/statements/async-generator/params-trailing-comma-single-param.js new file mode 100644 index 0000000000000000000000000000000000000000..a5c911f9a38514191029c928c6b8843fd3355871 --- /dev/null +++ b/test/language/statements/async-generator/params-trailing-comma-single-param.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/params/trailing-comma-single-param.case +// - src/params/default/async-gen-func-decl.template +/*--- +description: A trailing comma should not increase the respective length, using a single parameter (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + + Trailing comma in the parameters list + + 14.1 Function Definitions + + FormalParameters[Yield, Await] : FormalParameterList[?Yield, ?Await] , +---*/ + + +var callCount = 0; +// Stores a reference `ref` for case evaluation +async function* ref(a,) { + assert.sameValue(a, 42); + callCount = callCount + 1; +} + +ref(42, 39).next().then(() => { + assert.sameValue(callCount, 1, 'generator function invoked exactly once'); +}).then($DONE, $DONE); + +assert.sameValue(ref.length, 1, 'length is properly set'); diff --git a/test/language/statements/class/params-async-gen-meth-dflt-abrupt.js b/test/language/statements/class/params-async-gen-meth-dflt-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..68f5f7a1b7f0cee9bb802670617aa26239ed6db8 --- /dev/null +++ b/test/language/statements/class/params-async-gen-meth-dflt-abrupt.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/params/dflt-abrupt.case +// - src/params/error/cls-decl-async-gen-meth.template +/*--- +description: Abrupt completion returned by evaluation of initializer (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +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 + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto 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 { + async *method(_ = (function() { throw new Test262Error(); }())) { + + callCount = callCount + 1; + } +} + +assert.throws(Test262Error, function() { + C.prototype.method(); +}); +assert.sameValue(callCount, 0, 'method body not evaluated'); diff --git a/test/language/statements/class/params-async-gen-meth-dflt-arg-val-not-undefined.js b/test/language/statements/class/params-async-gen-meth-dflt-arg-val-not-undefined.js new file mode 100644 index 0000000000000000000000000000000000000000..0252ab3a7223507a0e93b858e40c319750edcbc0 --- /dev/null +++ b/test/language/statements/class/params-async-gen-meth-dflt-arg-val-not-undefined.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/params/dflt-arg-val-not-undefined.case +// - src/params/default/cls-decl-async-gen-meth.template +/*--- +description: Use of intializer when argument value is not `undefined` (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +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 + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto 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 { + 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.prototype.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/test/language/statements/class/params-async-gen-meth-dflt-arg-val-undefined.js b/test/language/statements/class/params-async-gen-meth-dflt-arg-val-undefined.js new file mode 100644 index 0000000000000000000000000000000000000000..833d873aaa31e464dac647de6c28cc7e15ebd6c7 --- /dev/null +++ b/test/language/statements/class/params-async-gen-meth-dflt-arg-val-undefined.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/params/dflt-arg-val-undefined.case +// - src/params/default/cls-decl-async-gen-meth.template +/*--- +description: Use of intializer when argument value is `undefined` (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +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 + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto 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 { + 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.prototype.method; + +ref(undefined, void 0).next().then(() => { + assert.sameValue(callCount, 1, 'method invoked exactly once'); +}).then($DONE, $DONE); diff --git a/test/language/statements/class/params-async-gen-meth-dflt-duplicates.js b/test/language/statements/class/params-async-gen-meth-dflt-duplicates.js new file mode 100644 index 0000000000000000000000000000000000000000..249d39f7bbaa6b7ae6b2a8085a67981b6b9a8404 --- /dev/null +++ b/test/language/statements/class/params-async-gen-meth-dflt-duplicates.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/params/dflt-duplicates.case +// - src/params/syntax/cls-decl-async-gen-meth.template +/*--- +description: It is a Syntax Error if BoundNames of FormalParameters contains any duplicate elements. (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [default-parameters, async-iteration] +flags: [generated] +negative: + phase: early + 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 + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto 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. + +---*/ + +class C { + async *method(x = 0, x) { + + } +} diff --git a/test/language/statements/class/params-async-gen-meth-dflt-ref-later.js b/test/language/statements/class/params-async-gen-meth-dflt-ref-later.js new file mode 100644 index 0000000000000000000000000000000000000000..e493997ba3c8adfdbe044fe410114f8341d7de7a --- /dev/null +++ b/test/language/statements/class/params-async-gen-meth-dflt-ref-later.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/params/dflt-ref-later.case +// - src/params/error/cls-decl-async-gen-meth.template +/*--- +description: Referencing a parameter that occurs later in the ParameterList (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +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 + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto 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 { + async *method(x = y, y) { + + callCount = callCount + 1; + } +} + +assert.throws(ReferenceError, function() { + C.prototype.method(); +}); +assert.sameValue(callCount, 0, 'method body not evaluated'); diff --git a/test/language/statements/class/params-async-gen-meth-dflt-ref-prior.js b/test/language/statements/class/params-async-gen-meth-dflt-ref-prior.js new file mode 100644 index 0000000000000000000000000000000000000000..01382f822f9d7d9922982817dd70bf3873857ac3 --- /dev/null +++ b/test/language/statements/class/params-async-gen-meth-dflt-ref-prior.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/params/dflt-ref-prior.case +// - src/params/default/cls-decl-async-gen-meth.template +/*--- +description: Referencing a parameter that occurs earlier in the ParameterList (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +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 + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto 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 { + 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.prototype.method; + +ref(3).next().then(() => { + assert.sameValue(callCount, 1, 'method invoked exactly once'); +}).then($DONE, $DONE); diff --git a/test/language/statements/class/params-async-gen-meth-dflt-ref-self.js b/test/language/statements/class/params-async-gen-meth-dflt-ref-self.js new file mode 100644 index 0000000000000000000000000000000000000000..a2145b880155a0ff5c0288e21504fe31f2d56ec5 --- /dev/null +++ b/test/language/statements/class/params-async-gen-meth-dflt-ref-self.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/params/dflt-ref-self.case +// - src/params/error/cls-decl-async-gen-meth.template +/*--- +description: Referencing a parameter from within its own initializer (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +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 + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto 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 { + async *method(x = x) { + + callCount = callCount + 1; + } +} + +assert.throws(ReferenceError, function() { + C.prototype.method(); +}); +assert.sameValue(callCount, 0, 'method body not evaluated'); diff --git a/test/language/statements/class/params-async-gen-meth-dflt-rest.js b/test/language/statements/class/params-async-gen-meth-dflt-rest.js new file mode 100644 index 0000000000000000000000000000000000000000..97291afb3da17eb192c365aabff33dfa7b3051a7 --- /dev/null +++ b/test/language/statements/class/params-async-gen-meth-dflt-rest.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/params/dflt-rest.case +// - src/params/syntax/cls-decl-async-gen-meth.template +/*--- +description: RestParameter does not support an initializer (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [default-parameters, async-iteration] +flags: [generated] +negative: + phase: early + 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 + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto 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] + +---*/ + +class C { + async *method(...x = []) { + + } +} diff --git a/test/language/statements/class/params-async-gen-meth-static-dflt-abrupt.js b/test/language/statements/class/params-async-gen-meth-static-dflt-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..906342013a0c277dbecec4871d9b8d36ef590b9f --- /dev/null +++ b/test/language/statements/class/params-async-gen-meth-static-dflt-abrupt.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/params/dflt-abrupt.case +// - src/params/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'); diff --git a/test/language/statements/class/params-async-gen-meth-static-dflt-arg-val-not-undefined.js b/test/language/statements/class/params-async-gen-meth-static-dflt-arg-val-not-undefined.js new file mode 100644 index 0000000000000000000000000000000000000000..638ffdda687a1ed9ecdc58d78865ccecedef23d7 --- /dev/null +++ b/test/language/statements/class/params-async-gen-meth-static-dflt-arg-val-not-undefined.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/params/dflt-arg-val-not-undefined.case +// - src/params/default/cls-decl-async-gen-meth-static.template +/*--- +description: Use of intializer when argument value is not `undefined` (static class expression 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/test/language/statements/class/params-async-gen-meth-static-dflt-arg-val-undefined.js b/test/language/statements/class/params-async-gen-meth-static-dflt-arg-val-undefined.js new file mode 100644 index 0000000000000000000000000000000000000000..e06aab096529369e9e16a01022fd256140aa42fd --- /dev/null +++ b/test/language/statements/class/params-async-gen-meth-static-dflt-arg-val-undefined.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/params/dflt-arg-val-undefined.case +// - src/params/default/cls-decl-async-gen-meth-static.template +/*--- +description: Use of intializer when argument value is `undefined` (static class expression 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/test/language/statements/class/params-async-gen-meth-static-dflt-duplicates.js b/test/language/statements/class/params-async-gen-meth-static-dflt-duplicates.js new file mode 100644 index 0000000000000000000000000000000000000000..71b0dbf18457ec0bfdc289cea0e0dc23ee908594 --- /dev/null +++ b/test/language/statements/class/params-async-gen-meth-static-dflt-duplicates.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/params/dflt-duplicates.case +// - src/params/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: early + 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. + +---*/ + + +class C { + static async *method(x = 0, x) { + + } +} diff --git a/test/language/statements/class/params-async-gen-meth-static-dflt-ref-later.js b/test/language/statements/class/params-async-gen-meth-static-dflt-ref-later.js new file mode 100644 index 0000000000000000000000000000000000000000..b04a655ac9698384bc9bafd7ce6dd9ac159ff07c --- /dev/null +++ b/test/language/statements/class/params-async-gen-meth-static-dflt-ref-later.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/params/dflt-ref-later.case +// - src/params/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'); diff --git a/test/language/statements/class/params-async-gen-meth-static-dflt-ref-prior.js b/test/language/statements/class/params-async-gen-meth-static-dflt-ref-prior.js new file mode 100644 index 0000000000000000000000000000000000000000..e4eef390ec317b5914836d39f02dcfbdb9fd00b6 --- /dev/null +++ b/test/language/statements/class/params-async-gen-meth-static-dflt-ref-prior.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/params/dflt-ref-prior.case +// - src/params/default/cls-decl-async-gen-meth-static.template +/*--- +description: Referencing a parameter that occurs earlier in the ParameterList (static class expression 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/test/language/statements/class/params-async-gen-meth-static-dflt-ref-self.js b/test/language/statements/class/params-async-gen-meth-static-dflt-ref-self.js new file mode 100644 index 0000000000000000000000000000000000000000..8ff36da0b8ecbffe9ed58d6579cf132c5ae73fee --- /dev/null +++ b/test/language/statements/class/params-async-gen-meth-static-dflt-ref-self.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/params/dflt-ref-self.case +// - src/params/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'); diff --git a/test/language/statements/class/params-async-gen-meth-static-dflt-rest.js b/test/language/statements/class/params-async-gen-meth-static-dflt-rest.js new file mode 100644 index 0000000000000000000000000000000000000000..367e6a6df47efa90cfaac316c334e86629a3c85e --- /dev/null +++ b/test/language/statements/class/params-async-gen-meth-static-dflt-rest.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/params/dflt-rest.case +// - src/params/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: early + 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] + +---*/ + + +class C { + static async *method(...x = []) { + + } +} diff --git a/test/language/statements/class/params-async-gen-meth-static-trailing-comma-dflt-param.js b/test/language/statements/class/params-async-gen-meth-static-trailing-comma-dflt-param.js new file mode 100644 index 0000000000000000000000000000000000000000..9e1c6b1bca3eaad3e8f4dd3024895e617beefc0c --- /dev/null +++ b/test/language/statements/class/params-async-gen-meth-static-trailing-comma-dflt-param.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/params/trailing-comma-dflt-param.case +// - src/params/default/cls-decl-async-gen-meth-static.template +/*--- +description: A trailing comma should not increase the respective length, using default parameters (static class expression 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/test/language/statements/class/params-async-gen-meth-static-trailing-comma-multiple-param.js b/test/language/statements/class/params-async-gen-meth-static-trailing-comma-multiple-param.js new file mode 100644 index 0000000000000000000000000000000000000000..65f08dfdf95b3d9d2e2afd088bf9b703d231b8e7 --- /dev/null +++ b/test/language/statements/class/params-async-gen-meth-static-trailing-comma-multiple-param.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/params/trailing-comma-multiple-param.case +// - src/params/default/cls-decl-async-gen-meth-static.template +/*--- +description: A trailing comma should not increase the respective length, using multiple parameters (static class expression 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/test/language/statements/class/params-async-gen-meth-static-trailing-comma-rest-early-error.js b/test/language/statements/class/params-async-gen-meth-static-trailing-comma-rest-early-error.js new file mode 100644 index 0000000000000000000000000000000000000000..8d616a80f57f87964867e4f4c8e2dbda8f345c72 --- /dev/null +++ b/test/language/statements/class/params-async-gen-meth-static-trailing-comma-rest-early-error.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/params/trailing-comma-rest-early-error.case +// - src/params/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: early + 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] +---*/ + + +class C { + static async *method(...a,) { + + } +} diff --git a/test/language/statements/class/params-async-gen-meth-static-trailing-comma-single-param.js b/test/language/statements/class/params-async-gen-meth-static-trailing-comma-single-param.js new file mode 100644 index 0000000000000000000000000000000000000000..2b8aa496f07586370cc33ffa8d2f581fefa07095 --- /dev/null +++ b/test/language/statements/class/params-async-gen-meth-static-trailing-comma-single-param.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/params/trailing-comma-single-param.case +// - src/params/default/cls-decl-async-gen-meth-static.template +/*--- +description: A trailing comma should not increase the respective length, using a single parameter (static class expression 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/test/language/statements/class/params-async-gen-meth-trailing-comma-dflt-param.js b/test/language/statements/class/params-async-gen-meth-trailing-comma-dflt-param.js new file mode 100644 index 0000000000000000000000000000000000000000..16b87a2c0cdff34da16970705cd1620cbac8d508 --- /dev/null +++ b/test/language/statements/class/params-async-gen-meth-trailing-comma-dflt-param.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/params/trailing-comma-dflt-param.case +// - src/params/default/cls-decl-async-gen-meth.template +/*--- +description: A trailing comma should not increase the respective length, using default parameters (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +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 + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto 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 { + 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.prototype.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/test/language/statements/class/params-async-gen-meth-trailing-comma-multiple-param.js b/test/language/statements/class/params-async-gen-meth-trailing-comma-multiple-param.js new file mode 100644 index 0000000000000000000000000000000000000000..3920841dc5fb6487c104f509b3dfd484657ad450 --- /dev/null +++ b/test/language/statements/class/params-async-gen-meth-trailing-comma-multiple-param.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/params/trailing-comma-multiple-param.case +// - src/params/default/cls-decl-async-gen-meth.template +/*--- +description: A trailing comma should not increase the respective length, using multiple parameters (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +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 + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto 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 { + 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.prototype.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/test/language/statements/class/params-async-gen-meth-trailing-comma-rest-early-error.js b/test/language/statements/class/params-async-gen-meth-trailing-comma-rest-early-error.js new file mode 100644 index 0000000000000000000000000000000000000000..482ba93b79504854b14dba57e4a0c55ab7ad17f9 --- /dev/null +++ b/test/language/statements/class/params-async-gen-meth-trailing-comma-rest-early-error.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/params/trailing-comma-rest-early-error.case +// - src/params/syntax/cls-decl-async-gen-meth.template +/*--- +description: It's a syntax error if a FunctionRestParameter is followed by a trailing comma (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated] +negative: + phase: early + 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 + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto 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] +---*/ + +class C { + async *method(...a,) { + + } +} diff --git a/test/language/statements/class/params-async-gen-meth-trailing-comma-single-param.js b/test/language/statements/class/params-async-gen-meth-trailing-comma-single-param.js new file mode 100644 index 0000000000000000000000000000000000000000..4e950fc9f6ad25d6ff29d67719834b160d63311b --- /dev/null +++ b/test/language/statements/class/params-async-gen-meth-trailing-comma-single-param.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/params/trailing-comma-single-param.case +// - src/params/default/cls-decl-async-gen-meth.template +/*--- +description: A trailing comma should not increase the respective length, using a single parameter (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +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 + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto 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 { + async *method(a,) { + assert.sameValue(a, 42); + callCount = callCount + 1; + } +} + +// Stores a reference `ref` for case evaluation +var ref = C.prototype.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');