diff --git a/src/dstr-binding/error/async-gen-func-decl-dflt.template b/src/dstr-binding/error/async-gen-func-decl-dflt.template new file mode 100644 index 0000000000..73788c2574 --- /dev/null +++ b/src/dstr-binding/error/async-gen-func-decl-dflt.template @@ -0,0 +1,25 @@ +// 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/dstr-dflt- +name: async generator function declaration (default parameter) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] +---*/ + +async function* f(/*{ elems }*/ = /*{ vals }*/) { + /*{ body }*/ +}; + +assert.throws(/*{ error }*/, function() { + f(); +}); diff --git a/src/dstr-binding/error/async-gen-func-decl.template b/src/dstr-binding/error/async-gen-func-decl.template new file mode 100644 index 0000000000..50e3ca2c77 --- /dev/null +++ b/src/dstr-binding/error/async-gen-func-decl.template @@ -0,0 +1,25 @@ +// 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/dstr- +name: async generator function declaration +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] +---*/ + +async function* f(/*{ elems }*/) { + /*{ body }*/ +}; + +assert.throws(/*{ error }*/, function() { + f(/*{ vals }*/); +}); diff --git a/src/dstr-binding/error/async-gen-func-expr-dflt.template b/src/dstr-binding/error/async-gen-func-expr-dflt.template new file mode 100644 index 0000000000..c7c9d3457c --- /dev/null +++ b/src/dstr-binding/error/async-gen-func-expr-dflt.template @@ -0,0 +1,25 @@ +// 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/dstr-dflt- +name: async generator function expression (default parameter) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] +---*/ + +var f = async function*(/*{ elems }*/ = /*{ vals }*/) { + /*{ body }*/ +}; + +assert.throws(/*{ error }*/, function() { + f(); +}); diff --git a/src/dstr-binding/error/async-gen-func-expr.template b/src/dstr-binding/error/async-gen-func-expr.template new file mode 100644 index 0000000000..8da6fd8cde --- /dev/null +++ b/src/dstr-binding/error/async-gen-func-expr.template @@ -0,0 +1,26 @@ +// 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/dstr- +name: async generator function expression +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] +---*/ + +var f; +f = async function*(/*{ elems }*/) { + /*{ body }*/ +}; + +assert.throws(/*{ error }*/, function() { + f(/*{ vals }*/); +}); diff --git a/src/dstr-binding/error/async-gen-func-named-expr-dflt.template b/src/dstr-binding/error/async-gen-func-named-expr-dflt.template new file mode 100644 index 0000000000..8cb7da7808 --- /dev/null +++ b/src/dstr-binding/error/async-gen-func-named-expr-dflt.template @@ -0,0 +1,26 @@ +// 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/dstr-named-dflt- +name: async generator named function expression (default parameter) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] +---*/ + +var f; +f = async function* g(/*{ elems }*/ = /*{ vals }*/) { + /*{ body }*/ +}; + +assert.throws(/*{ error }*/, function() { + f(); +}); diff --git a/src/dstr-binding/error/async-gen-func-named-expr.template b/src/dstr-binding/error/async-gen-func-named-expr.template new file mode 100644 index 0000000000..cf9176ff24 --- /dev/null +++ b/src/dstr-binding/error/async-gen-func-named-expr.template @@ -0,0 +1,26 @@ +// 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/dstr-named- +name: async generator named function expression +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] +---*/ + +var f; +f = async function* g(/*{ elems }*/) { + /*{ body }*/ +}; + +assert.throws(/*{ error }*/, function() { + f(/*{ vals }*/); +}); diff --git a/src/dstr-binding/error/async-gen-meth.template b/src/dstr-binding/error/async-gen-meth.template new file mode 100644 index 0000000000..a98c034f7a --- /dev/null +++ b/src/dstr-binding/error/async-gen-meth.template @@ -0,0 +1,32 @@ +// 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/object/dstr-async-gen-meth- +name: async generator method +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +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). + [...] +---*/ + +var obj = { + async *method(/*{ elems }*/) { + /*{ body }*/ + } +}; + +assert.throws(/*{ error }*/, function() { + obj.method(/*{ vals }*/); +}); diff --git a/src/dstr-binding/error/async-gen-method-dflt.template b/src/dstr-binding/error/async-gen-method-dflt.template new file mode 100644 index 0000000000..fd787e49c5 --- /dev/null +++ b/src/dstr-binding/error/async-gen-method-dflt.template @@ -0,0 +1,32 @@ +// 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/object/dstr-async-gen-meth-dflt- +name: async generator method (default parameter) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +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). + [...] +---*/ + +var obj = { + async *method(/*{ elems }*/ = /*{ vals }*/) { + /*{ body }*/ + } +}; + +assert.throws(/*{ error }*/, function() { + obj.method(); +}); diff --git a/src/dstr-binding/error/cls-decl-async-gen-meth-dflt.template b/src/dstr-binding/error/cls-decl-async-gen-meth-dflt.template new file mode 100644 index 0000000000..4a2bcc6aa3 --- /dev/null +++ b/src/dstr-binding/error/cls-decl-async-gen-meth-dflt.template @@ -0,0 +1,52 @@ +// 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/dstr-async-gen-meth-dflt- +name: class expression async generator method (default parameters) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +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). + [...] +---*/ + +class C { + async *method(/*{ elems }*/ = /*{ vals }*/) { + /*{ body }*/ + } +}; + +var method = C.prototype.method; + +assert.throws(/*{ error }*/, function() { + method(); +}); diff --git a/src/dstr-binding/error/cls-decl-async-gen-meth-static-dflt.template b/src/dstr-binding/error/cls-decl-async-gen-meth-static-dflt.template new file mode 100644 index 0000000000..1794cd64e7 --- /dev/null +++ b/src/dstr-binding/error/cls-decl-async-gen-meth-static-dflt.template @@ -0,0 +1,52 @@ +// 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/dstr-async-gen-meth-static-dflt- +name: static class expression async generator method (default parameter) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +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). + [...] +---*/ + +class C { + static async *method(/*{ elems }*/ = /*{ vals }*/) { + /*{ body }*/ + } +}; + +var method = C.method; + +assert.throws(/*{ error }*/, function() { + method(); +}); diff --git a/src/dstr-binding/error/cls-decl-async-gen-meth-static.template b/src/dstr-binding/error/cls-decl-async-gen-meth-static.template new file mode 100644 index 0000000000..98038e374a --- /dev/null +++ b/src/dstr-binding/error/cls-decl-async-gen-meth-static.template @@ -0,0 +1,52 @@ +// 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/dstr-async-gen-meth-static- +name: static class expression async generator method +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +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). + [...] +---*/ + +class C { + static async *method(/*{ elems }*/) { + /*{ body }*/ + } +}; + +var method = C.method; + +assert.throws(/*{ error }*/, function() { + method(/*{ vals }*/); +}); diff --git a/src/dstr-binding/error/cls-decl-async-gen-meth.template b/src/dstr-binding/error/cls-decl-async-gen-meth.template new file mode 100644 index 0000000000..25745f17c3 --- /dev/null +++ b/src/dstr-binding/error/cls-decl-async-gen-meth.template @@ -0,0 +1,52 @@ +// 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/dstr-async-gen-meth- +name: class expression method +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +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). + [...] +---*/ + +class C { + async *method(/*{ elems }*/) { + /*{ body }*/ + } +}; + +var method = C.prototype.method; + +assert.throws(/*{ error }*/, function() { + method(/*{ vals }*/); +}); diff --git a/src/dstr-binding/error/cls-expr-async-gen-meth-dflt.template b/src/dstr-binding/error/cls-expr-async-gen-meth-dflt.template new file mode 100644 index 0000000000..05f0c41e20 --- /dev/null +++ b/src/dstr-binding/error/cls-expr-async-gen-meth-dflt.template @@ -0,0 +1,53 @@ +// 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/class/dstr-async-gen-meth-dflt- +name: class expression async generator method (default parameter) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +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). + [...] +---*/ + +var C = class { + async *method(/*{ elems }*/ = /*{ vals }*/) { + /*{ body }*/ + } +}; + +var method = C.prototype.method; + +assert.throws(/*{ error }*/, function() { + method(); +}); diff --git a/src/dstr-binding/error/cls-expr-async-gen-meth-static-dflt.template b/src/dstr-binding/error/cls-expr-async-gen-meth-static-dflt.template new file mode 100644 index 0000000000..37fc8cb668 --- /dev/null +++ b/src/dstr-binding/error/cls-expr-async-gen-meth-static-dflt.template @@ -0,0 +1,53 @@ +// 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/class/dstr-async-gen-meth-static-dflt- +name: static class expression async generator method (default parameter) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +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). + [...] +---*/ + +var C = class { + static async *method(/*{ elems }*/ = /*{ vals }*/) { + /*{ body }*/ + } +}; + +var method = C.method; + +assert.throws(/*{ error }*/, function() { + method(); +}); diff --git a/src/dstr-binding/error/cls-expr-async-gen-meth-static.template b/src/dstr-binding/error/cls-expr-async-gen-meth-static.template new file mode 100644 index 0000000000..0830cf4470 --- /dev/null +++ b/src/dstr-binding/error/cls-expr-async-gen-meth-static.template @@ -0,0 +1,53 @@ +// 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/class/dstr-async-gen-meth-static- +name: static class expression async generator method +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +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). + [...] +---*/ + +var C = class { + static async *method(/*{ elems }*/) { + /*{ body }*/ + } +}; + +var method = C.method; + +assert.throws(/*{ error }*/, function() { + method(/*{ vals }*/); +}); diff --git a/src/dstr-binding/error/cls-expr-async-gen-meth.template b/src/dstr-binding/error/cls-expr-async-gen-meth.template new file mode 100644 index 0000000000..0e7433a4d7 --- /dev/null +++ b/src/dstr-binding/error/cls-expr-async-gen-meth.template @@ -0,0 +1,53 @@ +// 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/class/dstr-async-gen-meth- +name: class expression method +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +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). + [...] +---*/ + +var C = class { + async *method(/*{ elems }*/) { + /*{ body }*/ + } +}; + +var method = C.prototype.method; + +assert.throws(/*{ error }*/, function() { + method(/*{ vals }*/); +}); diff --git a/test/language/expressions/async-generator/dstr-ary-init-iter-get-err.js b/test/language/expressions/async-generator/dstr-ary-init-iter-get-err.js new file mode 100644 index 0000000000..deac79348f --- /dev/null +++ b/test/language/expressions/async-generator/dstr-ary-init-iter-get-err.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/async-gen-func-expr.template +/*--- +description: Abrupt completion returned by GetIterator (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [Symbol.iterator, async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). + +---*/ +var iter = {}; +iter[Symbol.iterator] = function() { + throw new Test262Error(); +}; + + +var f; +f = async function*([x]) { + +}; + +assert.throws(Test262Error, function() { + f(iter); +}); diff --git a/test/language/expressions/async-generator/dstr-ary-ptrn-elem-ary-val-null.js b/test/language/expressions/async-generator/dstr-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000..f97e13e02f --- /dev/null +++ b/test/language/expressions/async-generator/dstr-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,46 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-val-null.case +// - src/dstr-binding/error/async-gen-func-expr.template +/*--- +description: Nested array destructuring with a null value (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). +---*/ + + +var f; +f = async function*([[x]]) { + +}; + +assert.throws(TypeError, function() { + f([null]); +}); diff --git a/test/language/expressions/async-generator/dstr-ary-ptrn-elem-id-init-throws.js b/test/language/expressions/async-generator/dstr-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000..69bb942dff --- /dev/null +++ b/test/language/expressions/async-generator/dstr-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-throws.case +// - src/dstr-binding/error/async-gen-func-expr.template +/*--- +description: Destructuring initializer returns an abrupt completion (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ + + +var f; +f = async function*([x = (function() { throw new Test262Error(); })()]) { + +}; + +assert.throws(Test262Error, function() { + f([undefined]); +}); diff --git a/test/language/expressions/async-generator/dstr-ary-ptrn-elem-id-init-unresolvable.js b/test/language/expressions/async-generator/dstr-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000..b456599b8c --- /dev/null +++ b/test/language/expressions/async-generator/dstr-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-unresolvable.case +// - src/dstr-binding/error/async-gen-func-expr.template +/*--- +description: Destructuring initializer is an unresolvable reference (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + + +var f; +f = async function*([ x = unresolvableReference ]) { + +}; + +assert.throws(ReferenceError, function() { + f([]); +}); diff --git a/test/language/expressions/async-generator/dstr-ary-ptrn-elem-id-iter-step-err.js b/test/language/expressions/async-generator/dstr-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000..ae8ba5a07d --- /dev/null +++ b/test/language/expressions/async-generator/dstr-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,45 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-step-err.case +// - src/dstr-binding/error/async-gen-func-expr.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). +---*/ +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + throw new Test262Error(); + } + }; +}; + + +var f; +f = async function*([x]) { + +}; + +assert.throws(Test262Error, function() { + f(g); +}); diff --git a/test/language/expressions/async-generator/dstr-ary-ptrn-elem-id-iter-val-err.js b/test/language/expressions/async-generator/dstr-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000..9d5190d5e1 --- /dev/null +++ b/test/language/expressions/async-generator/dstr-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-err.case +// - src/dstr-binding/error/async-gen-func-expr.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(v). +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + + +var f; +f = async function*([x]) { + +}; + +assert.throws(Test262Error, function() { + f(g); +}); diff --git a/test/language/expressions/async-generator/dstr-ary-ptrn-elem-obj-val-null.js b/test/language/expressions/async-generator/dstr-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000..a535d5a7f5 --- /dev/null +++ b/test/language/expressions/async-generator/dstr-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,46 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-null.case +// - src/dstr-binding/error/async-gen-func-expr.template +/*--- +description: Nested object destructuring with a null value (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + + +var f; +f = async function*([{ x }]) { + +}; + +assert.throws(TypeError, function() { + f([null]); +}); diff --git a/test/language/expressions/async-generator/dstr-ary-ptrn-elem-obj-val-undef.js b/test/language/expressions/async-generator/dstr-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000..93f395a0e9 --- /dev/null +++ b/test/language/expressions/async-generator/dstr-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,46 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-undef.case +// - src/dstr-binding/error/async-gen-func-expr.template +/*--- +description: Nested object destructuring with a value of `undefined` (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + + +var f; +f = async function*([{ x }]) { + +}; + +assert.throws(TypeError, function() { + f([]); +}); diff --git a/test/language/expressions/async-generator/dstr-ary-ptrn-elision-step-err.js b/test/language/expressions/async-generator/dstr-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000..e4354ddc2a --- /dev/null +++ b/test/language/expressions/async-generator/dstr-ary-ptrn-elision-step-err.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/async-gen-func-expr.template +/*--- +description: Elision advances iterator and forwards abrupt completions (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [generator, async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + +---*/ +var following = 0; +var iter =function* () { + throw new Test262Error(); + following += 1; +}(); + + +var f; +f = async function*([,]) { + +}; + +assert.throws(Test262Error, function() { + f(iter); +}); + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); diff --git a/test/language/expressions/async-generator/dstr-ary-ptrn-rest-id-elision-next-err.js b/test/language/expressions/async-generator/dstr-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000..77a86424ae --- /dev/null +++ b/test/language/expressions/async-generator/dstr-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision-next-err.case +// - src/dstr-binding/error/async-gen-func-expr.template +/*--- +description: Rest element following elision elements (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [generators, async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. + +---*/ +var iter = (function*() { throw new Test262Error(); })(); + + +var f; +f = async function*([, ...x]) { + +}; + +assert.throws(Test262Error, function() { + f(iter); +}); diff --git a/test/language/expressions/async-generator/dstr-ary-ptrn-rest-id-iter-step-err.js b/test/language/expressions/async-generator/dstr-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000..ddd9df4527 --- /dev/null +++ b/test/language/expressions/async-generator/dstr-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case +// - src/dstr-binding/error/async-gen-func-expr.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [generators, async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + a. If iteratorRecord.[[done]] is false, + i. Let next be IteratorStep(iteratorRecord.[[iterator]]). + ii. If next is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(next). + +---*/ +var first = 0; +var second = 0; +var iter = function*() { + first += 1; + throw new Test262Error(); + second += 1; +}(); + + +var f; +f = async function*([...x]) { + +}; + +assert.throws(Test262Error, function() { + f(iter); +}); + +iter.next(); +assert.sameValue(first, 1); +assert.sameValue(second, 0, 'Iterator is closed following abrupt completion.'); diff --git a/test/language/expressions/async-generator/dstr-ary-ptrn-rest-id-iter-val-err.js b/test/language/expressions/async-generator/dstr-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000..54088f5484 --- /dev/null +++ b/test/language/expressions/async-generator/dstr-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-val-err.case +// - src/dstr-binding/error/async-gen-func-expr.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [Symbol.iterator, async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + c. Let nextValue be IteratorValue(next). + d. If nextValue is an abrupt completion, set iteratorRecord.[[done]] to + true. + e. ReturnIfAbrupt(nextValue). + +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + + +var f; +f = async function*([...x]) { + +}; + +assert.throws(Test262Error, function() { + f(iter); +}); diff --git a/test/language/expressions/async-generator/dstr-dflt-ary-init-iter-get-err.js b/test/language/expressions/async-generator/dstr-dflt-ary-init-iter-get-err.js new file mode 100644 index 0000000000..c4a7574d16 --- /dev/null +++ b/test/language/expressions/async-generator/dstr-dflt-ary-init-iter-get-err.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/async-gen-func-expr-dflt.template +/*--- +description: Abrupt completion returned by GetIterator (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [Symbol.iterator, async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). + +---*/ +var iter = {}; +iter[Symbol.iterator] = function() { + throw new Test262Error(); +}; + + +var f = async function*([x] = iter) { + +}; + +assert.throws(Test262Error, function() { + f(); +}); diff --git a/test/language/expressions/async-generator/dstr-dflt-ary-ptrn-elem-ary-val-null.js b/test/language/expressions/async-generator/dstr-dflt-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000..04ed87e429 --- /dev/null +++ b/test/language/expressions/async-generator/dstr-dflt-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,45 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-val-null.case +// - src/dstr-binding/error/async-gen-func-expr-dflt.template +/*--- +description: Nested array destructuring with a null value (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). +---*/ + + +var f = async function*([[x]] = [null]) { + +}; + +assert.throws(TypeError, function() { + f(); +}); diff --git a/test/language/expressions/async-generator/dstr-dflt-ary-ptrn-elem-id-init-throws.js b/test/language/expressions/async-generator/dstr-dflt-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000..1d0a61b354 --- /dev/null +++ b/test/language/expressions/async-generator/dstr-dflt-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-throws.case +// - src/dstr-binding/error/async-gen-func-expr-dflt.template +/*--- +description: Destructuring initializer returns an abrupt completion (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ + + +var f = async function*([x = (function() { throw new Test262Error(); })()] = [undefined]) { + +}; + +assert.throws(Test262Error, function() { + f(); +}); diff --git a/test/language/expressions/async-generator/dstr-dflt-ary-ptrn-elem-id-init-unresolvable.js b/test/language/expressions/async-generator/dstr-dflt-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000..3f195860ea --- /dev/null +++ b/test/language/expressions/async-generator/dstr-dflt-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-unresolvable.case +// - src/dstr-binding/error/async-gen-func-expr-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + + +var f = async function*([ x = unresolvableReference ] = []) { + +}; + +assert.throws(ReferenceError, function() { + f(); +}); diff --git a/test/language/expressions/async-generator/dstr-dflt-ary-ptrn-elem-id-iter-step-err.js b/test/language/expressions/async-generator/dstr-dflt-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000..f89def763b --- /dev/null +++ b/test/language/expressions/async-generator/dstr-dflt-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-step-err.case +// - src/dstr-binding/error/async-gen-func-expr-dflt.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). +---*/ +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + throw new Test262Error(); + } + }; +}; + + +var f = async function*([x] = g) { + +}; + +assert.throws(Test262Error, function() { + f(); +}); diff --git a/test/language/expressions/async-generator/dstr-dflt-ary-ptrn-elem-id-iter-val-err.js b/test/language/expressions/async-generator/dstr-dflt-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000..8cded00556 --- /dev/null +++ b/test/language/expressions/async-generator/dstr-dflt-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-err.case +// - src/dstr-binding/error/async-gen-func-expr-dflt.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(v). +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + + +var f = async function*([x] = g) { + +}; + +assert.throws(Test262Error, function() { + f(); +}); diff --git a/test/language/expressions/async-generator/dstr-dflt-ary-ptrn-elem-obj-val-null.js b/test/language/expressions/async-generator/dstr-dflt-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000..3b351a7a93 --- /dev/null +++ b/test/language/expressions/async-generator/dstr-dflt-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,45 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-null.case +// - src/dstr-binding/error/async-gen-func-expr-dflt.template +/*--- +description: Nested object destructuring with a null value (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + + +var f = async function*([{ x }] = [null]) { + +}; + +assert.throws(TypeError, function() { + f(); +}); diff --git a/test/language/expressions/async-generator/dstr-dflt-ary-ptrn-elem-obj-val-undef.js b/test/language/expressions/async-generator/dstr-dflt-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000..2e89689c55 --- /dev/null +++ b/test/language/expressions/async-generator/dstr-dflt-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,45 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-undef.case +// - src/dstr-binding/error/async-gen-func-expr-dflt.template +/*--- +description: Nested object destructuring with a value of `undefined` (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + + +var f = async function*([{ x }] = []) { + +}; + +assert.throws(TypeError, function() { + f(); +}); diff --git a/test/language/expressions/async-generator/dstr-dflt-ary-ptrn-elision-step-err.js b/test/language/expressions/async-generator/dstr-dflt-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000..dc9240b50e --- /dev/null +++ b/test/language/expressions/async-generator/dstr-dflt-ary-ptrn-elision-step-err.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/async-gen-func-expr-dflt.template +/*--- +description: Elision advances iterator and forwards abrupt completions (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [generator, async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + +---*/ +var following = 0; +var iter =function* () { + throw new Test262Error(); + following += 1; +}(); + + +var f = async function*([,] = iter) { + +}; + +assert.throws(Test262Error, function() { + f(); +}); + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); diff --git a/test/language/expressions/async-generator/dstr-dflt-ary-ptrn-rest-id-elision-next-err.js b/test/language/expressions/async-generator/dstr-dflt-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000..19c04746e8 --- /dev/null +++ b/test/language/expressions/async-generator/dstr-dflt-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision-next-err.case +// - src/dstr-binding/error/async-gen-func-expr-dflt.template +/*--- +description: Rest element following elision elements (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [generators, async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. + +---*/ +var iter = (function*() { throw new Test262Error(); })(); + + +var f = async function*([, ...x] = iter) { + +}; + +assert.throws(Test262Error, function() { + f(); +}); diff --git a/test/language/expressions/async-generator/dstr-dflt-ary-ptrn-rest-id-iter-step-err.js b/test/language/expressions/async-generator/dstr-dflt-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000..9d95c067d4 --- /dev/null +++ b/test/language/expressions/async-generator/dstr-dflt-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,49 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case +// - src/dstr-binding/error/async-gen-func-expr-dflt.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [generators, async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + a. If iteratorRecord.[[done]] is false, + i. Let next be IteratorStep(iteratorRecord.[[iterator]]). + ii. If next is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(next). + +---*/ +var first = 0; +var second = 0; +var iter = function*() { + first += 1; + throw new Test262Error(); + second += 1; +}(); + + +var f = async function*([...x] = iter) { + +}; + +assert.throws(Test262Error, function() { + f(); +}); + +iter.next(); +assert.sameValue(first, 1); +assert.sameValue(second, 0, 'Iterator is closed following abrupt completion.'); diff --git a/test/language/expressions/async-generator/dstr-dflt-ary-ptrn-rest-id-iter-val-err.js b/test/language/expressions/async-generator/dstr-dflt-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000..aa8a32ed37 --- /dev/null +++ b/test/language/expressions/async-generator/dstr-dflt-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-val-err.case +// - src/dstr-binding/error/async-gen-func-expr-dflt.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [Symbol.iterator, async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + c. Let nextValue be IteratorValue(next). + d. If nextValue is an abrupt completion, set iteratorRecord.[[done]] to + true. + e. ReturnIfAbrupt(nextValue). + +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + + +var f = async function*([...x] = iter) { + +}; + +assert.throws(Test262Error, function() { + f(); +}); diff --git a/test/language/expressions/async-generator/dstr-dflt-obj-init-null.js b/test/language/expressions/async-generator/dstr-dflt-obj-init-null.js new file mode 100644 index 0000000000..b681e82880 --- /dev/null +++ b/test/language/expressions/async-generator/dstr-dflt-obj-init-null.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/async-gen-func-expr-dflt.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + + +var f = async function*({} = null) { + +}; + +assert.throws(TypeError, function() { + f(); +}); diff --git a/test/language/expressions/async-generator/dstr-dflt-obj-init-undefined.js b/test/language/expressions/async-generator/dstr-dflt-obj-init-undefined.js new file mode 100644 index 0000000000..b44399e7cf --- /dev/null +++ b/test/language/expressions/async-generator/dstr-dflt-obj-init-undefined.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/async-gen-func-expr-dflt.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + + +var f = async function*({} = undefined) { + +}; + +assert.throws(TypeError, function() { + f(); +}); diff --git a/test/language/expressions/async-generator/dstr-dflt-obj-ptrn-id-get-value-err.js b/test/language/expressions/async-generator/dstr-dflt-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000..4c8084d7dc --- /dev/null +++ b/test/language/expressions/async-generator/dstr-dflt-obj-ptrn-id-get-value-err.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-get-value-err.case +// - src/dstr-binding/error/async-gen-func-expr-dflt.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. Let v be GetV(value, propertyName). + 5. ReturnIfAbrupt(v). +---*/ +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + + +var f = async function*({ poisoned } = poisonedProperty) { + +}; + +assert.throws(Test262Error, function() { + f(); +}); diff --git a/test/language/expressions/async-generator/dstr-dflt-obj-ptrn-id-init-throws.js b/test/language/expressions/async-generator/dstr-dflt-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000..63354b25a3 --- /dev/null +++ b/test/language/expressions/async-generator/dstr-dflt-obj-ptrn-id-init-throws.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/async-gen-func-expr-dflt.template +/*--- +description: Error thrown when evaluating the initializer (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + + +var f = async function*({ x = thrower() } = {}) { + +}; + +assert.throws(Test262Error, function() { + f(); +}); diff --git a/test/language/expressions/async-generator/dstr-dflt-obj-ptrn-id-init-unresolvable.js b/test/language/expressions/async-generator/dstr-dflt-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000..96f77126bc --- /dev/null +++ b/test/language/expressions/async-generator/dstr-dflt-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/async-gen-func-expr-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + + +var f = async function*({ x = unresolvableReference } = {}) { + +}; + +assert.throws(ReferenceError, function() { + f(); +}); diff --git a/test/language/expressions/async-generator/dstr-dflt-obj-ptrn-list-err.js b/test/language/expressions/async-generator/dstr-dflt-obj-ptrn-list-err.js new file mode 100644 index 0000000000..49d5b24265 --- /dev/null +++ b/test/language/expressions/async-generator/dstr-dflt-obj-ptrn-list-err.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/async-gen-func-expr-dflt.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPropertyList : BindingPropertyList , BindingProperty + + 1. Let status be the result of performing BindingInitialization for + BindingPropertyList using value and environment as arguments. + 2. ReturnIfAbrupt(status). +---*/ +var initCount = 0; +function thrower() { + throw new Test262Error(); +} + + +var f = async function*({ a, b = thrower(), c = ++initCount } = {}) { + +}; + +assert.throws(Test262Error, function() { + f(); +}); + +assert.sameValue(initCount, 0); diff --git a/test/language/expressions/async-generator/dstr-dflt-obj-ptrn-prop-ary-value-null.js b/test/language/expressions/async-generator/dstr-dflt-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000..d89287dce1 --- /dev/null +++ b/test/language/expressions/async-generator/dstr-dflt-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,34 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-value-null.case +// - src/dstr-binding/error/async-gen-func-expr-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + + +var f = async function*({ w: [x, y, z] = [4, 5, 6] } = { w: null }) { + +}; + +assert.throws(TypeError, function() { + f(); +}); diff --git a/test/language/expressions/async-generator/dstr-dflt-obj-ptrn-prop-eval-err.js b/test/language/expressions/async-generator/dstr-dflt-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000..1c9bbf461a --- /dev/null +++ b/test/language/expressions/async-generator/dstr-dflt-obj-ptrn-prop-eval-err.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/async-gen-func-expr-dflt.template +/*--- +description: Evaluation of property name returns an abrupt completion (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingProperty : PropertyName : BindingElement + + 1. Let P be the result of evaluating PropertyName + 2. ReturnIfAbrupt(P). +---*/ +function thrower() { + throw new Test262Error(); +} + + +var f = async function*({ [thrower()]: x } = {}) { + +}; + +assert.throws(Test262Error, function() { + f(); +}); diff --git a/test/language/expressions/async-generator/dstr-dflt-obj-ptrn-prop-id-get-value-err.js b/test/language/expressions/async-generator/dstr-dflt-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000..251e0e7cd4 --- /dev/null +++ b/test/language/expressions/async-generator/dstr-dflt-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-get-value-err.case +// - src/dstr-binding/error/async-gen-func-expr-dflt.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. Let v be GetV(value, propertyName). + 2. ReturnIfAbrupt(v). +---*/ +var initEvalCount = 0; +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + + +var f = async function*({ poisoned: x = ++initEvalCount } = poisonedProperty) { + +}; + +assert.throws(Test262Error, function() { + f(); +}); + +assert.sameValue(initEvalCount, 0); diff --git a/test/language/expressions/async-generator/dstr-dflt-obj-ptrn-prop-id-init-throws.js b/test/language/expressions/async-generator/dstr-dflt-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000..9f5d120f47 --- /dev/null +++ b/test/language/expressions/async-generator/dstr-dflt-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-throws.case +// - src/dstr-binding/error/async-gen-func-expr-dflt.template +/*--- +description: Error thrown when evaluating the initializer (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + + +var f = async function*({ x: y = thrower() } = {}) { + +}; + +assert.throws(Test262Error, function() { + f(); +}); diff --git a/test/language/expressions/async-generator/dstr-dflt-obj-ptrn-prop-id-init-unresolvable.js b/test/language/expressions/async-generator/dstr-dflt-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000..cfc4c93261 --- /dev/null +++ b/test/language/expressions/async-generator/dstr-dflt-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-unresolvable.case +// - src/dstr-binding/error/async-gen-func-expr-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + + +var f = async function*({ x: y = unresolvableReference } = {}) { + +}; + +assert.throws(ReferenceError, function() { + f(); +}); diff --git a/test/language/expressions/async-generator/dstr-dflt-obj-ptrn-prop-obj-value-null.js b/test/language/expressions/async-generator/dstr-dflt-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000..740614fda4 --- /dev/null +++ b/test/language/expressions/async-generator/dstr-dflt-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,34 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-null.case +// - src/dstr-binding/error/async-gen-func-expr-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + + +var f = async function*({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: null }) { + +}; + +assert.throws(TypeError, function() { + f(); +}); diff --git a/test/language/expressions/async-generator/dstr-dflt-obj-ptrn-prop-obj-value-undef.js b/test/language/expressions/async-generator/dstr-dflt-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000..76637c0fe1 --- /dev/null +++ b/test/language/expressions/async-generator/dstr-dflt-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,34 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-undef.case +// - src/dstr-binding/error/async-gen-func-expr-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (async generator function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + + +var f = async function*({ w: { x, y, z } = undefined } = { }) { + +}; + +assert.throws(TypeError, function() { + f(); +}); diff --git a/test/language/expressions/async-generator/dstr-named-ary-init-iter-get-err.js b/test/language/expressions/async-generator/dstr-named-ary-init-iter-get-err.js new file mode 100644 index 0000000000..3538016cc6 --- /dev/null +++ b/test/language/expressions/async-generator/dstr-named-ary-init-iter-get-err.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/async-gen-func-named-expr.template +/*--- +description: Abrupt completion returned by GetIterator (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [Symbol.iterator, async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). + +---*/ +var iter = {}; +iter[Symbol.iterator] = function() { + throw new Test262Error(); +}; + + +var f; +f = async function* g([x]) { + +}; + +assert.throws(Test262Error, function() { + f(iter); +}); diff --git a/test/language/expressions/async-generator/dstr-named-ary-ptrn-elem-ary-val-null.js b/test/language/expressions/async-generator/dstr-named-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000..da8f1f9d55 --- /dev/null +++ b/test/language/expressions/async-generator/dstr-named-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,46 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-val-null.case +// - src/dstr-binding/error/async-gen-func-named-expr.template +/*--- +description: Nested array destructuring with a null value (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). +---*/ + + +var f; +f = async function* g([[x]]) { + +}; + +assert.throws(TypeError, function() { + f([null]); +}); diff --git a/test/language/expressions/async-generator/dstr-named-ary-ptrn-elem-id-init-throws.js b/test/language/expressions/async-generator/dstr-named-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000..5c83a6ef39 --- /dev/null +++ b/test/language/expressions/async-generator/dstr-named-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-throws.case +// - src/dstr-binding/error/async-gen-func-named-expr.template +/*--- +description: Destructuring initializer returns an abrupt completion (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ + + +var f; +f = async function* g([x = (function() { throw new Test262Error(); })()]) { + +}; + +assert.throws(Test262Error, function() { + f([undefined]); +}); diff --git a/test/language/expressions/async-generator/dstr-named-ary-ptrn-elem-id-init-unresolvable.js b/test/language/expressions/async-generator/dstr-named-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000..1c167b9766 --- /dev/null +++ b/test/language/expressions/async-generator/dstr-named-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-unresolvable.case +// - src/dstr-binding/error/async-gen-func-named-expr.template +/*--- +description: Destructuring initializer is an unresolvable reference (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + + +var f; +f = async function* g([ x = unresolvableReference ]) { + +}; + +assert.throws(ReferenceError, function() { + f([]); +}); diff --git a/test/language/expressions/async-generator/dstr-named-ary-ptrn-elem-id-iter-step-err.js b/test/language/expressions/async-generator/dstr-named-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000..7a221d816b --- /dev/null +++ b/test/language/expressions/async-generator/dstr-named-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,45 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-step-err.case +// - src/dstr-binding/error/async-gen-func-named-expr.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). +---*/ +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + throw new Test262Error(); + } + }; +}; + + +var f; +f = async function* g([x]) { + +}; + +assert.throws(Test262Error, function() { + f(g); +}); diff --git a/test/language/expressions/async-generator/dstr-named-ary-ptrn-elem-id-iter-val-err.js b/test/language/expressions/async-generator/dstr-named-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000..70b8b937fe --- /dev/null +++ b/test/language/expressions/async-generator/dstr-named-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-err.case +// - src/dstr-binding/error/async-gen-func-named-expr.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(v). +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + + +var f; +f = async function* g([x]) { + +}; + +assert.throws(Test262Error, function() { + f(g); +}); diff --git a/test/language/expressions/async-generator/dstr-named-ary-ptrn-elem-obj-val-null.js b/test/language/expressions/async-generator/dstr-named-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000..102929128b --- /dev/null +++ b/test/language/expressions/async-generator/dstr-named-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,46 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-null.case +// - src/dstr-binding/error/async-gen-func-named-expr.template +/*--- +description: Nested object destructuring with a null value (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + + +var f; +f = async function* g([{ x }]) { + +}; + +assert.throws(TypeError, function() { + f([null]); +}); diff --git a/test/language/expressions/async-generator/dstr-named-ary-ptrn-elem-obj-val-undef.js b/test/language/expressions/async-generator/dstr-named-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000..e35014cf82 --- /dev/null +++ b/test/language/expressions/async-generator/dstr-named-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,46 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-undef.case +// - src/dstr-binding/error/async-gen-func-named-expr.template +/*--- +description: Nested object destructuring with a value of `undefined` (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + + +var f; +f = async function* g([{ x }]) { + +}; + +assert.throws(TypeError, function() { + f([]); +}); diff --git a/test/language/expressions/async-generator/dstr-named-ary-ptrn-elision-step-err.js b/test/language/expressions/async-generator/dstr-named-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000..2ad0616eed --- /dev/null +++ b/test/language/expressions/async-generator/dstr-named-ary-ptrn-elision-step-err.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/async-gen-func-named-expr.template +/*--- +description: Elision advances iterator and forwards abrupt completions (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [generator, async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + +---*/ +var following = 0; +var iter =function* () { + throw new Test262Error(); + following += 1; +}(); + + +var f; +f = async function* g([,]) { + +}; + +assert.throws(Test262Error, function() { + f(iter); +}); + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); diff --git a/test/language/expressions/async-generator/dstr-named-ary-ptrn-rest-id-elision-next-err.js b/test/language/expressions/async-generator/dstr-named-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000..9598c8ea9d --- /dev/null +++ b/test/language/expressions/async-generator/dstr-named-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision-next-err.case +// - src/dstr-binding/error/async-gen-func-named-expr.template +/*--- +description: Rest element following elision elements (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [generators, async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. + +---*/ +var iter = (function*() { throw new Test262Error(); })(); + + +var f; +f = async function* g([, ...x]) { + +}; + +assert.throws(Test262Error, function() { + f(iter); +}); diff --git a/test/language/expressions/async-generator/dstr-named-ary-ptrn-rest-id-iter-step-err.js b/test/language/expressions/async-generator/dstr-named-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000..40d0539609 --- /dev/null +++ b/test/language/expressions/async-generator/dstr-named-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case +// - src/dstr-binding/error/async-gen-func-named-expr.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [generators, async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + a. If iteratorRecord.[[done]] is false, + i. Let next be IteratorStep(iteratorRecord.[[iterator]]). + ii. If next is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(next). + +---*/ +var first = 0; +var second = 0; +var iter = function*() { + first += 1; + throw new Test262Error(); + second += 1; +}(); + + +var f; +f = async function* g([...x]) { + +}; + +assert.throws(Test262Error, function() { + f(iter); +}); + +iter.next(); +assert.sameValue(first, 1); +assert.sameValue(second, 0, 'Iterator is closed following abrupt completion.'); diff --git a/test/language/expressions/async-generator/dstr-named-ary-ptrn-rest-id-iter-val-err.js b/test/language/expressions/async-generator/dstr-named-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000..a585102b18 --- /dev/null +++ b/test/language/expressions/async-generator/dstr-named-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-val-err.case +// - src/dstr-binding/error/async-gen-func-named-expr.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [Symbol.iterator, async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + c. Let nextValue be IteratorValue(next). + d. If nextValue is an abrupt completion, set iteratorRecord.[[done]] to + true. + e. ReturnIfAbrupt(nextValue). + +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + + +var f; +f = async function* g([...x]) { + +}; + +assert.throws(Test262Error, function() { + f(iter); +}); diff --git a/test/language/expressions/async-generator/dstr-named-dflt-ary-init-iter-get-err.js b/test/language/expressions/async-generator/dstr-named-dflt-ary-init-iter-get-err.js new file mode 100644 index 0000000000..4b9fae8d58 --- /dev/null +++ b/test/language/expressions/async-generator/dstr-named-dflt-ary-init-iter-get-err.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/async-gen-func-named-expr-dflt.template +/*--- +description: Abrupt completion returned by GetIterator (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [Symbol.iterator, async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). + +---*/ +var iter = {}; +iter[Symbol.iterator] = function() { + throw new Test262Error(); +}; + + +var f; +f = async function* g([x] = iter) { + +}; + +assert.throws(Test262Error, function() { + f(); +}); diff --git a/test/language/expressions/async-generator/dstr-named-dflt-ary-ptrn-elem-ary-val-null.js b/test/language/expressions/async-generator/dstr-named-dflt-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000..d353221556 --- /dev/null +++ b/test/language/expressions/async-generator/dstr-named-dflt-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,46 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-val-null.case +// - src/dstr-binding/error/async-gen-func-named-expr-dflt.template +/*--- +description: Nested array destructuring with a null value (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). +---*/ + + +var f; +f = async function* g([[x]] = [null]) { + +}; + +assert.throws(TypeError, function() { + f(); +}); diff --git a/test/language/expressions/async-generator/dstr-named-dflt-ary-ptrn-elem-id-init-throws.js b/test/language/expressions/async-generator/dstr-named-dflt-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000..1e2dd1f29c --- /dev/null +++ b/test/language/expressions/async-generator/dstr-named-dflt-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-throws.case +// - src/dstr-binding/error/async-gen-func-named-expr-dflt.template +/*--- +description: Destructuring initializer returns an abrupt completion (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ + + +var f; +f = async function* g([x = (function() { throw new Test262Error(); })()] = [undefined]) { + +}; + +assert.throws(Test262Error, function() { + f(); +}); diff --git a/test/language/expressions/async-generator/dstr-named-dflt-ary-ptrn-elem-id-init-unresolvable.js b/test/language/expressions/async-generator/dstr-named-dflt-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000..8b60a3168f --- /dev/null +++ b/test/language/expressions/async-generator/dstr-named-dflt-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-unresolvable.case +// - src/dstr-binding/error/async-gen-func-named-expr-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + + +var f; +f = async function* g([ x = unresolvableReference ] = []) { + +}; + +assert.throws(ReferenceError, function() { + f(); +}); diff --git a/test/language/expressions/async-generator/dstr-named-dflt-ary-ptrn-elem-id-iter-step-err.js b/test/language/expressions/async-generator/dstr-named-dflt-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000..239f839342 --- /dev/null +++ b/test/language/expressions/async-generator/dstr-named-dflt-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,45 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-step-err.case +// - src/dstr-binding/error/async-gen-func-named-expr-dflt.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). +---*/ +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + throw new Test262Error(); + } + }; +}; + + +var f; +f = async function* g([x] = g) { + +}; + +assert.throws(Test262Error, function() { + f(); +}); diff --git a/test/language/expressions/async-generator/dstr-named-dflt-ary-ptrn-elem-id-iter-val-err.js b/test/language/expressions/async-generator/dstr-named-dflt-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000..40c4b9f4e0 --- /dev/null +++ b/test/language/expressions/async-generator/dstr-named-dflt-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-err.case +// - src/dstr-binding/error/async-gen-func-named-expr-dflt.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(v). +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + + +var f; +f = async function* g([x] = g) { + +}; + +assert.throws(Test262Error, function() { + f(); +}); diff --git a/test/language/expressions/async-generator/dstr-named-dflt-ary-ptrn-elem-obj-val-null.js b/test/language/expressions/async-generator/dstr-named-dflt-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000..198bf8d9f2 --- /dev/null +++ b/test/language/expressions/async-generator/dstr-named-dflt-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,46 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-null.case +// - src/dstr-binding/error/async-gen-func-named-expr-dflt.template +/*--- +description: Nested object destructuring with a null value (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + + +var f; +f = async function* g([{ x }] = [null]) { + +}; + +assert.throws(TypeError, function() { + f(); +}); diff --git a/test/language/expressions/async-generator/dstr-named-dflt-ary-ptrn-elem-obj-val-undef.js b/test/language/expressions/async-generator/dstr-named-dflt-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000..c1d1442132 --- /dev/null +++ b/test/language/expressions/async-generator/dstr-named-dflt-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,46 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-undef.case +// - src/dstr-binding/error/async-gen-func-named-expr-dflt.template +/*--- +description: Nested object destructuring with a value of `undefined` (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + + +var f; +f = async function* g([{ x }] = []) { + +}; + +assert.throws(TypeError, function() { + f(); +}); diff --git a/test/language/expressions/async-generator/dstr-named-dflt-ary-ptrn-elision-step-err.js b/test/language/expressions/async-generator/dstr-named-dflt-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000..61ade396be --- /dev/null +++ b/test/language/expressions/async-generator/dstr-named-dflt-ary-ptrn-elision-step-err.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/async-gen-func-named-expr-dflt.template +/*--- +description: Elision advances iterator and forwards abrupt completions (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [generator, async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + +---*/ +var following = 0; +var iter =function* () { + throw new Test262Error(); + following += 1; +}(); + + +var f; +f = async function* g([,] = iter) { + +}; + +assert.throws(Test262Error, function() { + f(); +}); + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); diff --git a/test/language/expressions/async-generator/dstr-named-dflt-ary-ptrn-rest-id-elision-next-err.js b/test/language/expressions/async-generator/dstr-named-dflt-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000..7d3199bd2c --- /dev/null +++ b/test/language/expressions/async-generator/dstr-named-dflt-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision-next-err.case +// - src/dstr-binding/error/async-gen-func-named-expr-dflt.template +/*--- +description: Rest element following elision elements (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [generators, async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. + +---*/ +var iter = (function*() { throw new Test262Error(); })(); + + +var f; +f = async function* g([, ...x] = iter) { + +}; + +assert.throws(Test262Error, function() { + f(); +}); diff --git a/test/language/expressions/async-generator/dstr-named-dflt-ary-ptrn-rest-id-iter-step-err.js b/test/language/expressions/async-generator/dstr-named-dflt-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000..a67fe0a55c --- /dev/null +++ b/test/language/expressions/async-generator/dstr-named-dflt-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case +// - src/dstr-binding/error/async-gen-func-named-expr-dflt.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [generators, async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + a. If iteratorRecord.[[done]] is false, + i. Let next be IteratorStep(iteratorRecord.[[iterator]]). + ii. If next is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(next). + +---*/ +var first = 0; +var second = 0; +var iter = function*() { + first += 1; + throw new Test262Error(); + second += 1; +}(); + + +var f; +f = async function* g([...x] = iter) { + +}; + +assert.throws(Test262Error, function() { + f(); +}); + +iter.next(); +assert.sameValue(first, 1); +assert.sameValue(second, 0, 'Iterator is closed following abrupt completion.'); diff --git a/test/language/expressions/async-generator/dstr-named-dflt-ary-ptrn-rest-id-iter-val-err.js b/test/language/expressions/async-generator/dstr-named-dflt-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000..2e1ea0b2e3 --- /dev/null +++ b/test/language/expressions/async-generator/dstr-named-dflt-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-val-err.case +// - src/dstr-binding/error/async-gen-func-named-expr-dflt.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [Symbol.iterator, async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + c. Let nextValue be IteratorValue(next). + d. If nextValue is an abrupt completion, set iteratorRecord.[[done]] to + true. + e. ReturnIfAbrupt(nextValue). + +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + + +var f; +f = async function* g([...x] = iter) { + +}; + +assert.throws(Test262Error, function() { + f(); +}); diff --git a/test/language/expressions/async-generator/dstr-named-dflt-obj-init-null.js b/test/language/expressions/async-generator/dstr-named-dflt-obj-init-null.js new file mode 100644 index 0000000000..51c8438dfe --- /dev/null +++ b/test/language/expressions/async-generator/dstr-named-dflt-obj-init-null.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/async-gen-func-named-expr-dflt.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + + +var f; +f = async function* g({} = null) { + +}; + +assert.throws(TypeError, function() { + f(); +}); diff --git a/test/language/expressions/async-generator/dstr-named-dflt-obj-init-undefined.js b/test/language/expressions/async-generator/dstr-named-dflt-obj-init-undefined.js new file mode 100644 index 0000000000..4ac5808767 --- /dev/null +++ b/test/language/expressions/async-generator/dstr-named-dflt-obj-init-undefined.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/async-gen-func-named-expr-dflt.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + + +var f; +f = async function* g({} = undefined) { + +}; + +assert.throws(TypeError, function() { + f(); +}); diff --git a/test/language/expressions/async-generator/dstr-named-dflt-obj-ptrn-id-get-value-err.js b/test/language/expressions/async-generator/dstr-named-dflt-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000..b0c53ccb47 --- /dev/null +++ b/test/language/expressions/async-generator/dstr-named-dflt-obj-ptrn-id-get-value-err.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-get-value-err.case +// - src/dstr-binding/error/async-gen-func-named-expr-dflt.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. Let v be GetV(value, propertyName). + 5. ReturnIfAbrupt(v). +---*/ +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + + +var f; +f = async function* g({ poisoned } = poisonedProperty) { + +}; + +assert.throws(Test262Error, function() { + f(); +}); diff --git a/test/language/expressions/async-generator/dstr-named-dflt-obj-ptrn-id-init-throws.js b/test/language/expressions/async-generator/dstr-named-dflt-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000..730f7d9fd7 --- /dev/null +++ b/test/language/expressions/async-generator/dstr-named-dflt-obj-ptrn-id-init-throws.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/async-gen-func-named-expr-dflt.template +/*--- +description: Error thrown when evaluating the initializer (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + + +var f; +f = async function* g({ x = thrower() } = {}) { + +}; + +assert.throws(Test262Error, function() { + f(); +}); diff --git a/test/language/expressions/async-generator/dstr-named-dflt-obj-ptrn-id-init-unresolvable.js b/test/language/expressions/async-generator/dstr-named-dflt-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000..5b438616d1 --- /dev/null +++ b/test/language/expressions/async-generator/dstr-named-dflt-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/async-gen-func-named-expr-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + + +var f; +f = async function* g({ x = unresolvableReference } = {}) { + +}; + +assert.throws(ReferenceError, function() { + f(); +}); diff --git a/test/language/expressions/async-generator/dstr-named-dflt-obj-ptrn-list-err.js b/test/language/expressions/async-generator/dstr-named-dflt-obj-ptrn-list-err.js new file mode 100644 index 0000000000..54a282ee8c --- /dev/null +++ b/test/language/expressions/async-generator/dstr-named-dflt-obj-ptrn-list-err.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/async-gen-func-named-expr-dflt.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPropertyList : BindingPropertyList , BindingProperty + + 1. Let status be the result of performing BindingInitialization for + BindingPropertyList using value and environment as arguments. + 2. ReturnIfAbrupt(status). +---*/ +var initCount = 0; +function thrower() { + throw new Test262Error(); +} + + +var f; +f = async function* g({ a, b = thrower(), c = ++initCount } = {}) { + +}; + +assert.throws(Test262Error, function() { + f(); +}); + +assert.sameValue(initCount, 0); diff --git a/test/language/expressions/async-generator/dstr-named-dflt-obj-ptrn-prop-ary-value-null.js b/test/language/expressions/async-generator/dstr-named-dflt-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000..bf3408b2da --- /dev/null +++ b/test/language/expressions/async-generator/dstr-named-dflt-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-value-null.case +// - src/dstr-binding/error/async-gen-func-named-expr-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + + +var f; +f = async function* g({ w: [x, y, z] = [4, 5, 6] } = { w: null }) { + +}; + +assert.throws(TypeError, function() { + f(); +}); diff --git a/test/language/expressions/async-generator/dstr-named-dflt-obj-ptrn-prop-eval-err.js b/test/language/expressions/async-generator/dstr-named-dflt-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000..4a4cf9b87d --- /dev/null +++ b/test/language/expressions/async-generator/dstr-named-dflt-obj-ptrn-prop-eval-err.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/async-gen-func-named-expr-dflt.template +/*--- +description: Evaluation of property name returns an abrupt completion (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingProperty : PropertyName : BindingElement + + 1. Let P be the result of evaluating PropertyName + 2. ReturnIfAbrupt(P). +---*/ +function thrower() { + throw new Test262Error(); +} + + +var f; +f = async function* g({ [thrower()]: x } = {}) { + +}; + +assert.throws(Test262Error, function() { + f(); +}); diff --git a/test/language/expressions/async-generator/dstr-named-dflt-obj-ptrn-prop-id-get-value-err.js b/test/language/expressions/async-generator/dstr-named-dflt-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000..2f211a4b6f --- /dev/null +++ b/test/language/expressions/async-generator/dstr-named-dflt-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-get-value-err.case +// - src/dstr-binding/error/async-gen-func-named-expr-dflt.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. Let v be GetV(value, propertyName). + 2. ReturnIfAbrupt(v). +---*/ +var initEvalCount = 0; +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + + +var f; +f = async function* g({ poisoned: x = ++initEvalCount } = poisonedProperty) { + +}; + +assert.throws(Test262Error, function() { + f(); +}); + +assert.sameValue(initEvalCount, 0); diff --git a/test/language/expressions/async-generator/dstr-named-dflt-obj-ptrn-prop-id-init-throws.js b/test/language/expressions/async-generator/dstr-named-dflt-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000..52df5c222e --- /dev/null +++ b/test/language/expressions/async-generator/dstr-named-dflt-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-throws.case +// - src/dstr-binding/error/async-gen-func-named-expr-dflt.template +/*--- +description: Error thrown when evaluating the initializer (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + + +var f; +f = async function* g({ x: y = thrower() } = {}) { + +}; + +assert.throws(Test262Error, function() { + f(); +}); diff --git a/test/language/expressions/async-generator/dstr-named-dflt-obj-ptrn-prop-id-init-unresolvable.js b/test/language/expressions/async-generator/dstr-named-dflt-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000..4c43f93d53 --- /dev/null +++ b/test/language/expressions/async-generator/dstr-named-dflt-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-unresolvable.case +// - src/dstr-binding/error/async-gen-func-named-expr-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + + +var f; +f = async function* g({ x: y = unresolvableReference } = {}) { + +}; + +assert.throws(ReferenceError, function() { + f(); +}); diff --git a/test/language/expressions/async-generator/dstr-named-dflt-obj-ptrn-prop-obj-value-null.js b/test/language/expressions/async-generator/dstr-named-dflt-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000..db6b821299 --- /dev/null +++ b/test/language/expressions/async-generator/dstr-named-dflt-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-null.case +// - src/dstr-binding/error/async-gen-func-named-expr-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + + +var f; +f = async function* g({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: null }) { + +}; + +assert.throws(TypeError, function() { + f(); +}); diff --git a/test/language/expressions/async-generator/dstr-named-dflt-obj-ptrn-prop-obj-value-undef.js b/test/language/expressions/async-generator/dstr-named-dflt-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000..930a0fb4ea --- /dev/null +++ b/test/language/expressions/async-generator/dstr-named-dflt-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-undef.case +// - src/dstr-binding/error/async-gen-func-named-expr-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (async generator named function expression (default parameter)) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + + +var f; +f = async function* g({ w: { x, y, z } = undefined } = { }) { + +}; + +assert.throws(TypeError, function() { + f(); +}); diff --git a/test/language/expressions/async-generator/dstr-named-obj-init-null.js b/test/language/expressions/async-generator/dstr-named-obj-init-null.js new file mode 100644 index 0000000000..628134526a --- /dev/null +++ b/test/language/expressions/async-generator/dstr-named-obj-init-null.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/async-gen-func-named-expr.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + + +var f; +f = async function* g({}) { + +}; + +assert.throws(TypeError, function() { + f(null); +}); diff --git a/test/language/expressions/async-generator/dstr-named-obj-init-undefined.js b/test/language/expressions/async-generator/dstr-named-obj-init-undefined.js new file mode 100644 index 0000000000..06e01eaabf --- /dev/null +++ b/test/language/expressions/async-generator/dstr-named-obj-init-undefined.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/async-gen-func-named-expr.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + + +var f; +f = async function* g({}) { + +}; + +assert.throws(TypeError, function() { + f(undefined); +}); diff --git a/test/language/expressions/async-generator/dstr-named-obj-ptrn-id-get-value-err.js b/test/language/expressions/async-generator/dstr-named-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000..fe19aa07a8 --- /dev/null +++ b/test/language/expressions/async-generator/dstr-named-obj-ptrn-id-get-value-err.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-get-value-err.case +// - src/dstr-binding/error/async-gen-func-named-expr.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. Let v be GetV(value, propertyName). + 5. ReturnIfAbrupt(v). +---*/ +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + + +var f; +f = async function* g({ poisoned }) { + +}; + +assert.throws(Test262Error, function() { + f(poisonedProperty); +}); diff --git a/test/language/expressions/async-generator/dstr-named-obj-ptrn-id-init-throws.js b/test/language/expressions/async-generator/dstr-named-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000..52b6c4f369 --- /dev/null +++ b/test/language/expressions/async-generator/dstr-named-obj-ptrn-id-init-throws.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/async-gen-func-named-expr.template +/*--- +description: Error thrown when evaluating the initializer (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + + +var f; +f = async function* g({ x = thrower() }) { + +}; + +assert.throws(Test262Error, function() { + f({}); +}); diff --git a/test/language/expressions/async-generator/dstr-named-obj-ptrn-id-init-unresolvable.js b/test/language/expressions/async-generator/dstr-named-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000..75384a31cd --- /dev/null +++ b/test/language/expressions/async-generator/dstr-named-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/async-gen-func-named-expr.template +/*--- +description: Destructuring initializer is an unresolvable reference (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + + +var f; +f = async function* g({ x = unresolvableReference }) { + +}; + +assert.throws(ReferenceError, function() { + f({}); +}); diff --git a/test/language/expressions/async-generator/dstr-named-obj-ptrn-list-err.js b/test/language/expressions/async-generator/dstr-named-obj-ptrn-list-err.js new file mode 100644 index 0000000000..a0e7c5d00a --- /dev/null +++ b/test/language/expressions/async-generator/dstr-named-obj-ptrn-list-err.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/async-gen-func-named-expr.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPropertyList : BindingPropertyList , BindingProperty + + 1. Let status be the result of performing BindingInitialization for + BindingPropertyList using value and environment as arguments. + 2. ReturnIfAbrupt(status). +---*/ +var initCount = 0; +function thrower() { + throw new Test262Error(); +} + + +var f; +f = async function* g({ a, b = thrower(), c = ++initCount }) { + +}; + +assert.throws(Test262Error, function() { + f({}); +}); + +assert.sameValue(initCount, 0); diff --git a/test/language/expressions/async-generator/dstr-named-obj-ptrn-prop-ary-value-null.js b/test/language/expressions/async-generator/dstr-named-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000..d4b6fefcf3 --- /dev/null +++ b/test/language/expressions/async-generator/dstr-named-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-value-null.case +// - src/dstr-binding/error/async-gen-func-named-expr.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + + +var f; +f = async function* g({ w: [x, y, z] = [4, 5, 6] }) { + +}; + +assert.throws(TypeError, function() { + f({ w: null }); +}); diff --git a/test/language/expressions/async-generator/dstr-named-obj-ptrn-prop-eval-err.js b/test/language/expressions/async-generator/dstr-named-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000..ecd2c9f5d5 --- /dev/null +++ b/test/language/expressions/async-generator/dstr-named-obj-ptrn-prop-eval-err.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/async-gen-func-named-expr.template +/*--- +description: Evaluation of property name returns an abrupt completion (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingProperty : PropertyName : BindingElement + + 1. Let P be the result of evaluating PropertyName + 2. ReturnIfAbrupt(P). +---*/ +function thrower() { + throw new Test262Error(); +} + + +var f; +f = async function* g({ [thrower()]: x }) { + +}; + +assert.throws(Test262Error, function() { + f({}); +}); diff --git a/test/language/expressions/async-generator/dstr-named-obj-ptrn-prop-id-get-value-err.js b/test/language/expressions/async-generator/dstr-named-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000..029a5e5381 --- /dev/null +++ b/test/language/expressions/async-generator/dstr-named-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-get-value-err.case +// - src/dstr-binding/error/async-gen-func-named-expr.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. Let v be GetV(value, propertyName). + 2. ReturnIfAbrupt(v). +---*/ +var initEvalCount = 0; +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + + +var f; +f = async function* g({ poisoned: x = ++initEvalCount }) { + +}; + +assert.throws(Test262Error, function() { + f(poisonedProperty); +}); + +assert.sameValue(initEvalCount, 0); diff --git a/test/language/expressions/async-generator/dstr-named-obj-ptrn-prop-id-init-throws.js b/test/language/expressions/async-generator/dstr-named-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000..35267d3967 --- /dev/null +++ b/test/language/expressions/async-generator/dstr-named-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-throws.case +// - src/dstr-binding/error/async-gen-func-named-expr.template +/*--- +description: Error thrown when evaluating the initializer (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + + +var f; +f = async function* g({ x: y = thrower() }) { + +}; + +assert.throws(Test262Error, function() { + f({}); +}); diff --git a/test/language/expressions/async-generator/dstr-named-obj-ptrn-prop-id-init-unresolvable.js b/test/language/expressions/async-generator/dstr-named-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000..227d47ad31 --- /dev/null +++ b/test/language/expressions/async-generator/dstr-named-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-unresolvable.case +// - src/dstr-binding/error/async-gen-func-named-expr.template +/*--- +description: Destructuring initializer is an unresolvable reference (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + + +var f; +f = async function* g({ x: y = unresolvableReference }) { + +}; + +assert.throws(ReferenceError, function() { + f({}); +}); diff --git a/test/language/expressions/async-generator/dstr-named-obj-ptrn-prop-obj-value-null.js b/test/language/expressions/async-generator/dstr-named-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000..f04ff8effb --- /dev/null +++ b/test/language/expressions/async-generator/dstr-named-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-null.case +// - src/dstr-binding/error/async-gen-func-named-expr.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + + +var f; +f = async function* g({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) { + +}; + +assert.throws(TypeError, function() { + f({ w: null }); +}); diff --git a/test/language/expressions/async-generator/dstr-named-obj-ptrn-prop-obj-value-undef.js b/test/language/expressions/async-generator/dstr-named-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000..46dc290c0d --- /dev/null +++ b/test/language/expressions/async-generator/dstr-named-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-undef.case +// - src/dstr-binding/error/async-gen-func-named-expr.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (async generator named function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, strict). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + + +var f; +f = async function* g({ w: { x, y, z } = undefined }) { + +}; + +assert.throws(TypeError, function() { + f({ }); +}); diff --git a/test/language/expressions/async-generator/dstr-obj-init-null.js b/test/language/expressions/async-generator/dstr-obj-init-null.js new file mode 100644 index 0000000000..e14e8c9d42 --- /dev/null +++ b/test/language/expressions/async-generator/dstr-obj-init-null.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/async-gen-func-expr.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + + +var f; +f = async function*({}) { + +}; + +assert.throws(TypeError, function() { + f(null); +}); diff --git a/test/language/expressions/async-generator/dstr-obj-init-undefined.js b/test/language/expressions/async-generator/dstr-obj-init-undefined.js new file mode 100644 index 0000000000..ea7d3094d2 --- /dev/null +++ b/test/language/expressions/async-generator/dstr-obj-init-undefined.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/async-gen-func-expr.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + + +var f; +f = async function*({}) { + +}; + +assert.throws(TypeError, function() { + f(undefined); +}); diff --git a/test/language/expressions/async-generator/dstr-obj-ptrn-id-get-value-err.js b/test/language/expressions/async-generator/dstr-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000..85c173f5dd --- /dev/null +++ b/test/language/expressions/async-generator/dstr-obj-ptrn-id-get-value-err.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-get-value-err.case +// - src/dstr-binding/error/async-gen-func-expr.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. Let v be GetV(value, propertyName). + 5. ReturnIfAbrupt(v). +---*/ +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + + +var f; +f = async function*({ poisoned }) { + +}; + +assert.throws(Test262Error, function() { + f(poisonedProperty); +}); diff --git a/test/language/expressions/async-generator/dstr-obj-ptrn-id-init-throws.js b/test/language/expressions/async-generator/dstr-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000..031df62552 --- /dev/null +++ b/test/language/expressions/async-generator/dstr-obj-ptrn-id-init-throws.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/async-gen-func-expr.template +/*--- +description: Error thrown when evaluating the initializer (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + + +var f; +f = async function*({ x = thrower() }) { + +}; + +assert.throws(Test262Error, function() { + f({}); +}); diff --git a/test/language/expressions/async-generator/dstr-obj-ptrn-id-init-unresolvable.js b/test/language/expressions/async-generator/dstr-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000..ca74cd5108 --- /dev/null +++ b/test/language/expressions/async-generator/dstr-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/async-gen-func-expr.template +/*--- +description: Destructuring initializer is an unresolvable reference (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + + +var f; +f = async function*({ x = unresolvableReference }) { + +}; + +assert.throws(ReferenceError, function() { + f({}); +}); diff --git a/test/language/expressions/async-generator/dstr-obj-ptrn-list-err.js b/test/language/expressions/async-generator/dstr-obj-ptrn-list-err.js new file mode 100644 index 0000000000..92353674eb --- /dev/null +++ b/test/language/expressions/async-generator/dstr-obj-ptrn-list-err.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/async-gen-func-expr.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPropertyList : BindingPropertyList , BindingProperty + + 1. Let status be the result of performing BindingInitialization for + BindingPropertyList using value and environment as arguments. + 2. ReturnIfAbrupt(status). +---*/ +var initCount = 0; +function thrower() { + throw new Test262Error(); +} + + +var f; +f = async function*({ a, b = thrower(), c = ++initCount }) { + +}; + +assert.throws(Test262Error, function() { + f({}); +}); + +assert.sameValue(initCount, 0); diff --git a/test/language/expressions/async-generator/dstr-obj-ptrn-prop-ary-value-null.js b/test/language/expressions/async-generator/dstr-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000..9f4ea05e12 --- /dev/null +++ b/test/language/expressions/async-generator/dstr-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-value-null.case +// - src/dstr-binding/error/async-gen-func-expr.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + + +var f; +f = async function*({ w: [x, y, z] = [4, 5, 6] }) { + +}; + +assert.throws(TypeError, function() { + f({ w: null }); +}); diff --git a/test/language/expressions/async-generator/dstr-obj-ptrn-prop-eval-err.js b/test/language/expressions/async-generator/dstr-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000..df6418769a --- /dev/null +++ b/test/language/expressions/async-generator/dstr-obj-ptrn-prop-eval-err.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/async-gen-func-expr.template +/*--- +description: Evaluation of property name returns an abrupt completion (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingProperty : PropertyName : BindingElement + + 1. Let P be the result of evaluating PropertyName + 2. ReturnIfAbrupt(P). +---*/ +function thrower() { + throw new Test262Error(); +} + + +var f; +f = async function*({ [thrower()]: x }) { + +}; + +assert.throws(Test262Error, function() { + f({}); +}); diff --git a/test/language/expressions/async-generator/dstr-obj-ptrn-prop-id-get-value-err.js b/test/language/expressions/async-generator/dstr-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000..e8499f1fea --- /dev/null +++ b/test/language/expressions/async-generator/dstr-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-get-value-err.case +// - src/dstr-binding/error/async-gen-func-expr.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. Let v be GetV(value, propertyName). + 2. ReturnIfAbrupt(v). +---*/ +var initEvalCount = 0; +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + + +var f; +f = async function*({ poisoned: x = ++initEvalCount }) { + +}; + +assert.throws(Test262Error, function() { + f(poisonedProperty); +}); + +assert.sameValue(initEvalCount, 0); diff --git a/test/language/expressions/async-generator/dstr-obj-ptrn-prop-id-init-throws.js b/test/language/expressions/async-generator/dstr-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000..d50c41da56 --- /dev/null +++ b/test/language/expressions/async-generator/dstr-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-throws.case +// - src/dstr-binding/error/async-gen-func-expr.template +/*--- +description: Error thrown when evaluating the initializer (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + + +var f; +f = async function*({ x: y = thrower() }) { + +}; + +assert.throws(Test262Error, function() { + f({}); +}); diff --git a/test/language/expressions/async-generator/dstr-obj-ptrn-prop-id-init-unresolvable.js b/test/language/expressions/async-generator/dstr-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000..92a98928a9 --- /dev/null +++ b/test/language/expressions/async-generator/dstr-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-unresolvable.case +// - src/dstr-binding/error/async-gen-func-expr.template +/*--- +description: Destructuring initializer is an unresolvable reference (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + + +var f; +f = async function*({ x: y = unresolvableReference }) { + +}; + +assert.throws(ReferenceError, function() { + f({}); +}); diff --git a/test/language/expressions/async-generator/dstr-obj-ptrn-prop-obj-value-null.js b/test/language/expressions/async-generator/dstr-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000..9e41a2b4b0 --- /dev/null +++ b/test/language/expressions/async-generator/dstr-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-null.case +// - src/dstr-binding/error/async-gen-func-expr.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + + +var f; +f = async function*({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) { + +}; + +assert.throws(TypeError, function() { + f({ w: null }); +}); diff --git a/test/language/expressions/async-generator/dstr-obj-ptrn-prop-obj-value-undef.js b/test/language/expressions/async-generator/dstr-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000..9b599394bf --- /dev/null +++ b/test/language/expressions/async-generator/dstr-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-undef.case +// - src/dstr-binding/error/async-gen-func-expr.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (async generator function expression) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { + AsyncGeneratorBody } + + [...] + 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + + +var f; +f = async function*({ w: { x, y, z } = undefined }) { + +}; + +assert.throws(TypeError, function() { + f({ }); +}); diff --git a/test/language/expressions/class/dstr-async-gen-meth-ary-init-iter-get-err.js b/test/language/expressions/class/dstr-async-gen-meth-ary-init-iter-get-err.js new file mode 100644 index 0000000000..f7bc46ebff --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-ary-init-iter-get-err.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/cls-expr-async-gen-meth.template +/*--- +description: Abrupt completion returned by GetIterator (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [Symbol.iterator, 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. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). + +---*/ +var iter = {}; +iter[Symbol.iterator] = function() { + throw new Test262Error(); +}; + + +var C = class { + async *method([x]) { + + } +}; + +var method = C.prototype.method; + +assert.throws(Test262Error, function() { + method(iter); +}); diff --git a/test/language/expressions/class/dstr-async-gen-meth-ary-ptrn-elem-ary-val-null.js b/test/language/expressions/class/dstr-async-gen-meth-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000..abbbebb862 --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-val-null.case +// - src/dstr-binding/error/cls-expr-async-gen-meth.template +/*--- +description: Nested array destructuring with a null value (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). +---*/ + + +var C = class { + async *method([[x]]) { + + } +}; + +var method = C.prototype.method; + +assert.throws(TypeError, function() { + method([null]); +}); diff --git a/test/language/expressions/class/dstr-async-gen-meth-ary-ptrn-elem-id-init-throws.js b/test/language/expressions/class/dstr-async-gen-meth-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000..58b1391d0a --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-throws.case +// - src/dstr-binding/error/cls-expr-async-gen-meth.template +/*--- +description: Destructuring initializer returns an abrupt completion (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ + + +var C = class { + async *method([x = (function() { throw new Test262Error(); })()]) { + + } +}; + +var method = C.prototype.method; + +assert.throws(Test262Error, function() { + method([undefined]); +}); diff --git a/test/language/expressions/class/dstr-async-gen-meth-ary-ptrn-elem-id-init-unresolvable.js b/test/language/expressions/class/dstr-async-gen-meth-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000..bffc96da32 --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-unresolvable.case +// - src/dstr-binding/error/cls-expr-async-gen-meth.template +/*--- +description: Destructuring initializer is an unresolvable reference (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + + +var C = class { + async *method([ x = unresolvableReference ]) { + + } +}; + +var method = C.prototype.method; + +assert.throws(ReferenceError, function() { + method([]); +}); diff --git a/test/language/expressions/class/dstr-async-gen-meth-ary-ptrn-elem-id-iter-step-err.js b/test/language/expressions/class/dstr-async-gen-meth-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000..03b76f206a --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-step-err.case +// - src/dstr-binding/error/cls-expr-async-gen-meth.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). +---*/ +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + throw new Test262Error(); + } + }; +}; + + +var C = class { + async *method([x]) { + + } +}; + +var method = C.prototype.method; + +assert.throws(Test262Error, function() { + method(g); +}); diff --git a/test/language/expressions/class/dstr-async-gen-meth-ary-ptrn-elem-id-iter-val-err.js b/test/language/expressions/class/dstr-async-gen-meth-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000..6cc33e6ad2 --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-err.case +// - src/dstr-binding/error/cls-expr-async-gen-meth.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(v). +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + + +var C = class { + async *method([x]) { + + } +}; + +var method = C.prototype.method; + +assert.throws(Test262Error, function() { + method(g); +}); diff --git a/test/language/expressions/class/dstr-async-gen-meth-ary-ptrn-elem-obj-val-null.js b/test/language/expressions/class/dstr-async-gen-meth-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000..b3d53e363b --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-null.case +// - src/dstr-binding/error/cls-expr-async-gen-meth.template +/*--- +description: Nested object destructuring with a null value (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + + +var C = class { + async *method([{ x }]) { + + } +}; + +var method = C.prototype.method; + +assert.throws(TypeError, function() { + method([null]); +}); diff --git a/test/language/expressions/class/dstr-async-gen-meth-ary-ptrn-elem-obj-val-undef.js b/test/language/expressions/class/dstr-async-gen-meth-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000..eebc9eacb1 --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-undef.case +// - src/dstr-binding/error/cls-expr-async-gen-meth.template +/*--- +description: Nested object destructuring with a value of `undefined` (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + + +var C = class { + async *method([{ x }]) { + + } +}; + +var method = C.prototype.method; + +assert.throws(TypeError, function() { + method([]); +}); diff --git a/test/language/expressions/class/dstr-async-gen-meth-ary-ptrn-elision-step-err.js b/test/language/expressions/class/dstr-async-gen-meth-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000..473d000632 --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-ary-ptrn-elision-step-err.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/cls-expr-async-gen-meth.template +/*--- +description: Elision advances iterator and forwards abrupt completions (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generator, 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. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + +---*/ +var following = 0; +var iter =function* () { + throw new Test262Error(); + following += 1; +}(); + + +var C = class { + async *method([,]) { + + } +}; + +var method = C.prototype.method; + +assert.throws(Test262Error, function() { + method(iter); +}); + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); diff --git a/test/language/expressions/class/dstr-async-gen-meth-ary-ptrn-rest-id-elision-next-err.js b/test/language/expressions/class/dstr-async-gen-meth-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000..fb088c389f --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision-next-err.case +// - src/dstr-binding/error/cls-expr-async-gen-meth.template +/*--- +description: Rest element following elision elements (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, 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. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. + +---*/ +var iter = (function*() { throw new Test262Error(); })(); + + +var C = class { + async *method([, ...x]) { + + } +}; + +var method = C.prototype.method; + +assert.throws(Test262Error, function() { + method(iter); +}); diff --git a/test/language/expressions/class/dstr-async-gen-meth-ary-ptrn-rest-id-iter-step-err.js b/test/language/expressions/class/dstr-async-gen-meth-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000..64bb45c2be --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case +// - src/dstr-binding/error/cls-expr-async-gen-meth.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, 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. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + a. If iteratorRecord.[[done]] is false, + i. Let next be IteratorStep(iteratorRecord.[[iterator]]). + ii. If next is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(next). + +---*/ +var first = 0; +var second = 0; +var iter = function*() { + first += 1; + throw new Test262Error(); + second += 1; +}(); + + +var C = class { + async *method([...x]) { + + } +}; + +var method = C.prototype.method; + +assert.throws(Test262Error, function() { + method(iter); +}); + +iter.next(); +assert.sameValue(first, 1); +assert.sameValue(second, 0, 'Iterator is closed following abrupt completion.'); diff --git a/test/language/expressions/class/dstr-async-gen-meth-ary-ptrn-rest-id-iter-val-err.js b/test/language/expressions/class/dstr-async-gen-meth-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000..c86e2092a9 --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-val-err.case +// - src/dstr-binding/error/cls-expr-async-gen-meth.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [Symbol.iterator, 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. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + c. Let nextValue be IteratorValue(next). + d. If nextValue is an abrupt completion, set iteratorRecord.[[done]] to + true. + e. ReturnIfAbrupt(nextValue). + +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + + +var C = class { + async *method([...x]) { + + } +}; + +var method = C.prototype.method; + +assert.throws(Test262Error, function() { + method(iter); +}); diff --git a/test/language/expressions/class/dstr-async-gen-meth-dflt-ary-init-iter-get-err.js b/test/language/expressions/class/dstr-async-gen-meth-dflt-ary-init-iter-get-err.js new file mode 100644 index 0000000000..1fc4a2092a --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-dflt-ary-init-iter-get-err.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/cls-expr-async-gen-meth-dflt.template +/*--- +description: Abrupt completion returned by GetIterator (class expression async generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [Symbol.iterator, 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. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). + +---*/ +var iter = {}; +iter[Symbol.iterator] = function() { + throw new Test262Error(); +}; + + +var C = class { + async *method([x] = iter) { + + } +}; + +var method = C.prototype.method; + +assert.throws(Test262Error, function() { + method(); +}); diff --git a/test/language/expressions/class/dstr-async-gen-meth-dflt-ary-ptrn-elem-ary-val-null.js b/test/language/expressions/class/dstr-async-gen-meth-dflt-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000..2acef8f155 --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-dflt-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-val-null.case +// - src/dstr-binding/error/cls-expr-async-gen-meth-dflt.template +/*--- +description: Nested array destructuring with a null value (class expression async generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). +---*/ + + +var C = class { + async *method([[x]] = [null]) { + + } +}; + +var method = C.prototype.method; + +assert.throws(TypeError, function() { + method(); +}); diff --git a/test/language/expressions/class/dstr-async-gen-meth-dflt-ary-ptrn-elem-id-init-throws.js b/test/language/expressions/class/dstr-async-gen-meth-dflt-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000..79c1e34e4a --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-dflt-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-throws.case +// - src/dstr-binding/error/cls-expr-async-gen-meth-dflt.template +/*--- +description: Destructuring initializer returns an abrupt completion (class expression async generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ + + +var C = class { + async *method([x = (function() { throw new Test262Error(); })()] = [undefined]) { + + } +}; + +var method = C.prototype.method; + +assert.throws(Test262Error, function() { + method(); +}); diff --git a/test/language/expressions/class/dstr-async-gen-meth-dflt-ary-ptrn-elem-id-init-unresolvable.js b/test/language/expressions/class/dstr-async-gen-meth-dflt-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000..de63905491 --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-dflt-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-unresolvable.case +// - src/dstr-binding/error/cls-expr-async-gen-meth-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (class expression async generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + + +var C = class { + async *method([ x = unresolvableReference ] = []) { + + } +}; + +var method = C.prototype.method; + +assert.throws(ReferenceError, function() { + method(); +}); diff --git a/test/language/expressions/class/dstr-async-gen-meth-dflt-ary-ptrn-elem-id-iter-step-err.js b/test/language/expressions/class/dstr-async-gen-meth-dflt-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000..df934b31a8 --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-dflt-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-step-err.case +// - src/dstr-binding/error/cls-expr-async-gen-meth-dflt.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (class expression async generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). +---*/ +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + throw new Test262Error(); + } + }; +}; + + +var C = class { + async *method([x] = g) { + + } +}; + +var method = C.prototype.method; + +assert.throws(Test262Error, function() { + method(); +}); diff --git a/test/language/expressions/class/dstr-async-gen-meth-dflt-ary-ptrn-elem-id-iter-val-err.js b/test/language/expressions/class/dstr-async-gen-meth-dflt-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000..80b82c2071 --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-dflt-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-err.case +// - src/dstr-binding/error/cls-expr-async-gen-meth-dflt.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (class expression async generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(v). +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + + +var C = class { + async *method([x] = g) { + + } +}; + +var method = C.prototype.method; + +assert.throws(Test262Error, function() { + method(); +}); diff --git a/test/language/expressions/class/dstr-async-gen-meth-dflt-ary-ptrn-elem-obj-val-null.js b/test/language/expressions/class/dstr-async-gen-meth-dflt-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000..101ae3bf07 --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-dflt-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-null.case +// - src/dstr-binding/error/cls-expr-async-gen-meth-dflt.template +/*--- +description: Nested object destructuring with a null value (class expression async generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + + +var C = class { + async *method([{ x }] = [null]) { + + } +}; + +var method = C.prototype.method; + +assert.throws(TypeError, function() { + method(); +}); diff --git a/test/language/expressions/class/dstr-async-gen-meth-dflt-ary-ptrn-elem-obj-val-undef.js b/test/language/expressions/class/dstr-async-gen-meth-dflt-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000..de624a979e --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-dflt-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-undef.case +// - src/dstr-binding/error/cls-expr-async-gen-meth-dflt.template +/*--- +description: Nested object destructuring with a value of `undefined` (class expression async generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + + +var C = class { + async *method([{ x }] = []) { + + } +}; + +var method = C.prototype.method; + +assert.throws(TypeError, function() { + method(); +}); diff --git a/test/language/expressions/class/dstr-async-gen-meth-dflt-ary-ptrn-elision-step-err.js b/test/language/expressions/class/dstr-async-gen-meth-dflt-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000..be7acf1465 --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-dflt-ary-ptrn-elision-step-err.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/cls-expr-async-gen-meth-dflt.template +/*--- +description: Elision advances iterator and forwards abrupt completions (class expression async generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generator, 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. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + +---*/ +var following = 0; +var iter =function* () { + throw new Test262Error(); + following += 1; +}(); + + +var C = class { + async *method([,] = iter) { + + } +}; + +var method = C.prototype.method; + +assert.throws(Test262Error, function() { + method(); +}); + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); diff --git a/test/language/expressions/class/dstr-async-gen-meth-dflt-ary-ptrn-rest-id-elision-next-err.js b/test/language/expressions/class/dstr-async-gen-meth-dflt-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000..1e10fefd32 --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-dflt-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision-next-err.case +// - src/dstr-binding/error/cls-expr-async-gen-meth-dflt.template +/*--- +description: Rest element following elision elements (class expression async generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, 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. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. + +---*/ +var iter = (function*() { throw new Test262Error(); })(); + + +var C = class { + async *method([, ...x] = iter) { + + } +}; + +var method = C.prototype.method; + +assert.throws(Test262Error, function() { + method(); +}); diff --git a/test/language/expressions/class/dstr-async-gen-meth-dflt-ary-ptrn-rest-id-iter-step-err.js b/test/language/expressions/class/dstr-async-gen-meth-dflt-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000..660d1c4310 --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-dflt-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case +// - src/dstr-binding/error/cls-expr-async-gen-meth-dflt.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (class expression async generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, 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. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + a. If iteratorRecord.[[done]] is false, + i. Let next be IteratorStep(iteratorRecord.[[iterator]]). + ii. If next is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(next). + +---*/ +var first = 0; +var second = 0; +var iter = function*() { + first += 1; + throw new Test262Error(); + second += 1; +}(); + + +var C = class { + async *method([...x] = iter) { + + } +}; + +var method = C.prototype.method; + +assert.throws(Test262Error, function() { + method(); +}); + +iter.next(); +assert.sameValue(first, 1); +assert.sameValue(second, 0, 'Iterator is closed following abrupt completion.'); diff --git a/test/language/expressions/class/dstr-async-gen-meth-dflt-ary-ptrn-rest-id-iter-val-err.js b/test/language/expressions/class/dstr-async-gen-meth-dflt-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000..eff6797604 --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-dflt-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-val-err.case +// - src/dstr-binding/error/cls-expr-async-gen-meth-dflt.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (class expression async generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [Symbol.iterator, 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. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + c. Let nextValue be IteratorValue(next). + d. If nextValue is an abrupt completion, set iteratorRecord.[[done]] to + true. + e. ReturnIfAbrupt(nextValue). + +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + + +var C = class { + async *method([...x] = iter) { + + } +}; + +var method = C.prototype.method; + +assert.throws(Test262Error, function() { + method(); +}); diff --git a/test/language/expressions/class/dstr-async-gen-meth-dflt-obj-init-null.js b/test/language/expressions/class/dstr-async-gen-meth-dflt-obj-init-null.js new file mode 100644 index 0000000000..0fe18c18d0 --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-dflt-obj-init-null.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/cls-expr-async-gen-meth-dflt.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (class expression async generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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. + [...] + + 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). + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + + +var C = class { + async *method({} = null) { + + } +}; + +var method = C.prototype.method; + +assert.throws(TypeError, function() { + method(); +}); diff --git a/test/language/expressions/class/dstr-async-gen-meth-dflt-obj-init-undefined.js b/test/language/expressions/class/dstr-async-gen-meth-dflt-obj-init-undefined.js new file mode 100644 index 0000000000..8ddc08985e --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-dflt-obj-init-undefined.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/cls-expr-async-gen-meth-dflt.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (class expression async generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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. + [...] + + 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). + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + + +var C = class { + async *method({} = undefined) { + + } +}; + +var method = C.prototype.method; + +assert.throws(TypeError, function() { + method(); +}); diff --git a/test/language/expressions/class/dstr-async-gen-meth-dflt-obj-ptrn-id-get-value-err.js b/test/language/expressions/class/dstr-async-gen-meth-dflt-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000..e8c2688fc6 --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-dflt-obj-ptrn-id-get-value-err.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-get-value-err.case +// - src/dstr-binding/error/cls-expr-async-gen-meth-dflt.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (class expression async generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. Let v be GetV(value, propertyName). + 5. ReturnIfAbrupt(v). +---*/ +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + + +var C = class { + async *method({ poisoned } = poisonedProperty) { + + } +}; + +var method = C.prototype.method; + +assert.throws(Test262Error, function() { + method(); +}); diff --git a/test/language/expressions/class/dstr-async-gen-meth-dflt-obj-ptrn-id-init-throws.js b/test/language/expressions/class/dstr-async-gen-meth-dflt-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000..89b68586a7 --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-dflt-obj-ptrn-id-init-throws.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/cls-expr-async-gen-meth-dflt.template +/*--- +description: Error thrown when evaluating the initializer (class expression async generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + + +var C = class { + async *method({ x = thrower() } = {}) { + + } +}; + +var method = C.prototype.method; + +assert.throws(Test262Error, function() { + method(); +}); diff --git a/test/language/expressions/class/dstr-async-gen-meth-dflt-obj-ptrn-id-init-unresolvable.js b/test/language/expressions/class/dstr-async-gen-meth-dflt-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000..1c6126c513 --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-dflt-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/cls-expr-async-gen-meth-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (class expression async generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + + +var C = class { + async *method({ x = unresolvableReference } = {}) { + + } +}; + +var method = C.prototype.method; + +assert.throws(ReferenceError, function() { + method(); +}); diff --git a/test/language/expressions/class/dstr-async-gen-meth-dflt-obj-ptrn-list-err.js b/test/language/expressions/class/dstr-async-gen-meth-dflt-obj-ptrn-list-err.js new file mode 100644 index 0000000000..32c3a33e19 --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-dflt-obj-ptrn-list-err.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/cls-expr-async-gen-meth-dflt.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (class expression async generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPropertyList : BindingPropertyList , BindingProperty + + 1. Let status be the result of performing BindingInitialization for + BindingPropertyList using value and environment as arguments. + 2. ReturnIfAbrupt(status). +---*/ +var initCount = 0; +function thrower() { + throw new Test262Error(); +} + + +var C = class { + async *method({ a, b = thrower(), c = ++initCount } = {}) { + + } +}; + +var method = C.prototype.method; + +assert.throws(Test262Error, function() { + method(); +}); + +assert.sameValue(initCount, 0); diff --git a/test/language/expressions/class/dstr-async-gen-meth-dflt-obj-ptrn-prop-ary-value-null.js b/test/language/expressions/class/dstr-async-gen-meth-dflt-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000..8f971faff9 --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-dflt-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-value-null.case +// - src/dstr-binding/error/cls-expr-async-gen-meth-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (class expression async generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + + +var C = class { + async *method({ w: [x, y, z] = [4, 5, 6] } = { w: null }) { + + } +}; + +var method = C.prototype.method; + +assert.throws(TypeError, function() { + method(); +}); diff --git a/test/language/expressions/class/dstr-async-gen-meth-dflt-obj-ptrn-prop-eval-err.js b/test/language/expressions/class/dstr-async-gen-meth-dflt-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000..a3bfb32155 --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-dflt-obj-ptrn-prop-eval-err.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/cls-expr-async-gen-meth-dflt.template +/*--- +description: Evaluation of property name returns an abrupt completion (class expression async generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingProperty : PropertyName : BindingElement + + 1. Let P be the result of evaluating PropertyName + 2. ReturnIfAbrupt(P). +---*/ +function thrower() { + throw new Test262Error(); +} + + +var C = class { + async *method({ [thrower()]: x } = {}) { + + } +}; + +var method = C.prototype.method; + +assert.throws(Test262Error, function() { + method(); +}); diff --git a/test/language/expressions/class/dstr-async-gen-meth-dflt-obj-ptrn-prop-id-get-value-err.js b/test/language/expressions/class/dstr-async-gen-meth-dflt-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000..8eff330fd9 --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-dflt-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-get-value-err.case +// - src/dstr-binding/error/cls-expr-async-gen-meth-dflt.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (class expression async generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. Let v be GetV(value, propertyName). + 2. ReturnIfAbrupt(v). +---*/ +var initEvalCount = 0; +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + + +var C = class { + async *method({ poisoned: x = ++initEvalCount } = poisonedProperty) { + + } +}; + +var method = C.prototype.method; + +assert.throws(Test262Error, function() { + method(); +}); + +assert.sameValue(initEvalCount, 0); diff --git a/test/language/expressions/class/dstr-async-gen-meth-dflt-obj-ptrn-prop-id-init-throws.js b/test/language/expressions/class/dstr-async-gen-meth-dflt-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000..ab3c721793 --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-dflt-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-throws.case +// - src/dstr-binding/error/cls-expr-async-gen-meth-dflt.template +/*--- +description: Error thrown when evaluating the initializer (class expression async generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + + +var C = class { + async *method({ x: y = thrower() } = {}) { + + } +}; + +var method = C.prototype.method; + +assert.throws(Test262Error, function() { + method(); +}); diff --git a/test/language/expressions/class/dstr-async-gen-meth-dflt-obj-ptrn-prop-id-init-unresolvable.js b/test/language/expressions/class/dstr-async-gen-meth-dflt-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000..0c9dfe0db7 --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-dflt-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-unresolvable.case +// - src/dstr-binding/error/cls-expr-async-gen-meth-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (class expression async generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + + +var C = class { + async *method({ x: y = unresolvableReference } = {}) { + + } +}; + +var method = C.prototype.method; + +assert.throws(ReferenceError, function() { + method(); +}); diff --git a/test/language/expressions/class/dstr-async-gen-meth-dflt-obj-ptrn-prop-obj-value-null.js b/test/language/expressions/class/dstr-async-gen-meth-dflt-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000..12865eac52 --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-dflt-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-null.case +// - src/dstr-binding/error/cls-expr-async-gen-meth-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (class expression async generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + + +var C = class { + async *method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: null }) { + + } +}; + +var method = C.prototype.method; + +assert.throws(TypeError, function() { + method(); +}); diff --git a/test/language/expressions/class/dstr-async-gen-meth-dflt-obj-ptrn-prop-obj-value-undef.js b/test/language/expressions/class/dstr-async-gen-meth-dflt-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000..e4a24b377e --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-dflt-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-undef.case +// - src/dstr-binding/error/cls-expr-async-gen-meth-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (class expression async generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + + +var C = class { + async *method({ w: { x, y, z } = undefined } = { }) { + + } +}; + +var method = C.prototype.method; + +assert.throws(TypeError, function() { + method(); +}); diff --git a/test/language/expressions/class/dstr-async-gen-meth-obj-init-null.js b/test/language/expressions/class/dstr-async-gen-meth-obj-init-null.js new file mode 100644 index 0000000000..e79d85a635 --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-obj-init-null.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/cls-expr-async-gen-meth.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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. + [...] + + 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). + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + + +var C = class { + async *method({}) { + + } +}; + +var method = C.prototype.method; + +assert.throws(TypeError, function() { + method(null); +}); diff --git a/test/language/expressions/class/dstr-async-gen-meth-obj-init-undefined.js b/test/language/expressions/class/dstr-async-gen-meth-obj-init-undefined.js new file mode 100644 index 0000000000..52f830037a --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-obj-init-undefined.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/cls-expr-async-gen-meth.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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. + [...] + + 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). + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + + +var C = class { + async *method({}) { + + } +}; + +var method = C.prototype.method; + +assert.throws(TypeError, function() { + method(undefined); +}); diff --git a/test/language/expressions/class/dstr-async-gen-meth-obj-ptrn-id-get-value-err.js b/test/language/expressions/class/dstr-async-gen-meth-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000..7cffce1650 --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-obj-ptrn-id-get-value-err.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-get-value-err.case +// - src/dstr-binding/error/cls-expr-async-gen-meth.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. Let v be GetV(value, propertyName). + 5. ReturnIfAbrupt(v). +---*/ +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + + +var C = class { + async *method({ poisoned }) { + + } +}; + +var method = C.prototype.method; + +assert.throws(Test262Error, function() { + method(poisonedProperty); +}); diff --git a/test/language/expressions/class/dstr-async-gen-meth-obj-ptrn-id-init-throws.js b/test/language/expressions/class/dstr-async-gen-meth-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000..94ee79765b --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-obj-ptrn-id-init-throws.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/cls-expr-async-gen-meth.template +/*--- +description: Error thrown when evaluating the initializer (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + + +var C = class { + async *method({ x = thrower() }) { + + } +}; + +var method = C.prototype.method; + +assert.throws(Test262Error, function() { + method({}); +}); diff --git a/test/language/expressions/class/dstr-async-gen-meth-obj-ptrn-id-init-unresolvable.js b/test/language/expressions/class/dstr-async-gen-meth-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000..fd6c142f88 --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/cls-expr-async-gen-meth.template +/*--- +description: Destructuring initializer is an unresolvable reference (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + + +var C = class { + async *method({ x = unresolvableReference }) { + + } +}; + +var method = C.prototype.method; + +assert.throws(ReferenceError, function() { + method({}); +}); diff --git a/test/language/expressions/class/dstr-async-gen-meth-obj-ptrn-list-err.js b/test/language/expressions/class/dstr-async-gen-meth-obj-ptrn-list-err.js new file mode 100644 index 0000000000..9efea6cba5 --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-obj-ptrn-list-err.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/cls-expr-async-gen-meth.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPropertyList : BindingPropertyList , BindingProperty + + 1. Let status be the result of performing BindingInitialization for + BindingPropertyList using value and environment as arguments. + 2. ReturnIfAbrupt(status). +---*/ +var initCount = 0; +function thrower() { + throw new Test262Error(); +} + + +var C = class { + async *method({ a, b = thrower(), c = ++initCount }) { + + } +}; + +var method = C.prototype.method; + +assert.throws(Test262Error, function() { + method({}); +}); + +assert.sameValue(initCount, 0); diff --git a/test/language/expressions/class/dstr-async-gen-meth-obj-ptrn-prop-ary-value-null.js b/test/language/expressions/class/dstr-async-gen-meth-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000..82352b5309 --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-value-null.case +// - src/dstr-binding/error/cls-expr-async-gen-meth.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + + +var C = class { + async *method({ w: [x, y, z] = [4, 5, 6] }) { + + } +}; + +var method = C.prototype.method; + +assert.throws(TypeError, function() { + method({ w: null }); +}); diff --git a/test/language/expressions/class/dstr-async-gen-meth-obj-ptrn-prop-eval-err.js b/test/language/expressions/class/dstr-async-gen-meth-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000..653efc95af --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-obj-ptrn-prop-eval-err.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/cls-expr-async-gen-meth.template +/*--- +description: Evaluation of property name returns an abrupt completion (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingProperty : PropertyName : BindingElement + + 1. Let P be the result of evaluating PropertyName + 2. ReturnIfAbrupt(P). +---*/ +function thrower() { + throw new Test262Error(); +} + + +var C = class { + async *method({ [thrower()]: x }) { + + } +}; + +var method = C.prototype.method; + +assert.throws(Test262Error, function() { + method({}); +}); diff --git a/test/language/expressions/class/dstr-async-gen-meth-obj-ptrn-prop-id-get-value-err.js b/test/language/expressions/class/dstr-async-gen-meth-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000..72b247c026 --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-get-value-err.case +// - src/dstr-binding/error/cls-expr-async-gen-meth.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. Let v be GetV(value, propertyName). + 2. ReturnIfAbrupt(v). +---*/ +var initEvalCount = 0; +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + + +var C = class { + async *method({ poisoned: x = ++initEvalCount }) { + + } +}; + +var method = C.prototype.method; + +assert.throws(Test262Error, function() { + method(poisonedProperty); +}); + +assert.sameValue(initEvalCount, 0); diff --git a/test/language/expressions/class/dstr-async-gen-meth-obj-ptrn-prop-id-init-throws.js b/test/language/expressions/class/dstr-async-gen-meth-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000..7a8fc724ab --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-throws.case +// - src/dstr-binding/error/cls-expr-async-gen-meth.template +/*--- +description: Error thrown when evaluating the initializer (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + + +var C = class { + async *method({ x: y = thrower() }) { + + } +}; + +var method = C.prototype.method; + +assert.throws(Test262Error, function() { + method({}); +}); diff --git a/test/language/expressions/class/dstr-async-gen-meth-obj-ptrn-prop-id-init-unresolvable.js b/test/language/expressions/class/dstr-async-gen-meth-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000..3c9198bd02 --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-unresolvable.case +// - src/dstr-binding/error/cls-expr-async-gen-meth.template +/*--- +description: Destructuring initializer is an unresolvable reference (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + + +var C = class { + async *method({ x: y = unresolvableReference }) { + + } +}; + +var method = C.prototype.method; + +assert.throws(ReferenceError, function() { + method({}); +}); diff --git a/test/language/expressions/class/dstr-async-gen-meth-obj-ptrn-prop-obj-value-null.js b/test/language/expressions/class/dstr-async-gen-meth-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000..786d430083 --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-null.case +// - src/dstr-binding/error/cls-expr-async-gen-meth.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + + +var C = class { + async *method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) { + + } +}; + +var method = C.prototype.method; + +assert.throws(TypeError, function() { + method({ w: null }); +}); diff --git a/test/language/expressions/class/dstr-async-gen-meth-obj-ptrn-prop-obj-value-undef.js b/test/language/expressions/class/dstr-async-gen-meth-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000..d266e0cd98 --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-undef.case +// - src/dstr-binding/error/cls-expr-async-gen-meth.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + + +var C = class { + async *method({ w: { x, y, z } = undefined }) { + + } +}; + +var method = C.prototype.method; + +assert.throws(TypeError, function() { + method({ }); +}); diff --git a/test/language/expressions/class/dstr-async-gen-meth-static-ary-init-iter-get-err.js b/test/language/expressions/class/dstr-async-gen-meth-static-ary-init-iter-get-err.js new file mode 100644 index 0000000000..dae44bb040 --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-static-ary-init-iter-get-err.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/cls-expr-async-gen-meth-static.template +/*--- +description: Abrupt completion returned by GetIterator (static class expression async generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [Symbol.iterator, 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). + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). + +---*/ +var iter = {}; +iter[Symbol.iterator] = function() { + throw new Test262Error(); +}; + + +var C = class { + static async *method([x]) { + + } +}; + +var method = C.method; + +assert.throws(Test262Error, function() { + method(iter); +}); diff --git a/test/language/expressions/class/dstr-async-gen-meth-static-ary-ptrn-elem-ary-val-null.js b/test/language/expressions/class/dstr-async-gen-meth-static-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000..f32311559c --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-static-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-val-null.case +// - src/dstr-binding/error/cls-expr-async-gen-meth-static.template +/*--- +description: Nested array destructuring with a null value (static class expression async generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). +---*/ + + +var C = class { + static async *method([[x]]) { + + } +}; + +var method = C.method; + +assert.throws(TypeError, function() { + method([null]); +}); diff --git a/test/language/expressions/class/dstr-async-gen-meth-static-ary-ptrn-elem-id-init-throws.js b/test/language/expressions/class/dstr-async-gen-meth-static-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000..09276f8e6d --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-static-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-throws.case +// - src/dstr-binding/error/cls-expr-async-gen-meth-static.template +/*--- +description: Destructuring initializer returns an abrupt completion (static class expression async generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ + + +var C = class { + static async *method([x = (function() { throw new Test262Error(); })()]) { + + } +}; + +var method = C.method; + +assert.throws(Test262Error, function() { + method([undefined]); +}); diff --git a/test/language/expressions/class/dstr-async-gen-meth-static-ary-ptrn-elem-id-init-unresolvable.js b/test/language/expressions/class/dstr-async-gen-meth-static-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000..5a2c1b8694 --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-static-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-unresolvable.case +// - src/dstr-binding/error/cls-expr-async-gen-meth-static.template +/*--- +description: Destructuring initializer is an unresolvable reference (static class expression async generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + + +var C = class { + static async *method([ x = unresolvableReference ]) { + + } +}; + +var method = C.method; + +assert.throws(ReferenceError, function() { + method([]); +}); diff --git a/test/language/expressions/class/dstr-async-gen-meth-static-ary-ptrn-elem-id-iter-step-err.js b/test/language/expressions/class/dstr-async-gen-meth-static-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000..8889ce80e2 --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-static-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-step-err.case +// - src/dstr-binding/error/cls-expr-async-gen-meth-static.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (static class expression async generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). +---*/ +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + throw new Test262Error(); + } + }; +}; + + +var C = class { + static async *method([x]) { + + } +}; + +var method = C.method; + +assert.throws(Test262Error, function() { + method(g); +}); diff --git a/test/language/expressions/class/dstr-async-gen-meth-static-ary-ptrn-elem-id-iter-val-err.js b/test/language/expressions/class/dstr-async-gen-meth-static-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000..fe0a10a22d --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-static-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-err.case +// - src/dstr-binding/error/cls-expr-async-gen-meth-static.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (static class expression async generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(v). +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + + +var C = class { + static async *method([x]) { + + } +}; + +var method = C.method; + +assert.throws(Test262Error, function() { + method(g); +}); diff --git a/test/language/expressions/class/dstr-async-gen-meth-static-ary-ptrn-elem-obj-val-null.js b/test/language/expressions/class/dstr-async-gen-meth-static-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000..beb9b09622 --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-static-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-null.case +// - src/dstr-binding/error/cls-expr-async-gen-meth-static.template +/*--- +description: Nested object destructuring with a null value (static class expression async generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + + +var C = class { + static async *method([{ x }]) { + + } +}; + +var method = C.method; + +assert.throws(TypeError, function() { + method([null]); +}); diff --git a/test/language/expressions/class/dstr-async-gen-meth-static-ary-ptrn-elem-obj-val-undef.js b/test/language/expressions/class/dstr-async-gen-meth-static-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000..59b1d0a922 --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-static-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-undef.case +// - src/dstr-binding/error/cls-expr-async-gen-meth-static.template +/*--- +description: Nested object destructuring with a value of `undefined` (static class expression async generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + + +var C = class { + static async *method([{ x }]) { + + } +}; + +var method = C.method; + +assert.throws(TypeError, function() { + method([]); +}); diff --git a/test/language/expressions/class/dstr-async-gen-meth-static-ary-ptrn-elision-step-err.js b/test/language/expressions/class/dstr-async-gen-meth-static-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000..179569d107 --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-static-ary-ptrn-elision-step-err.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/cls-expr-async-gen-meth-static.template +/*--- +description: Elision advances iterator and forwards abrupt completions (static class expression async generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generator, 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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + +---*/ +var following = 0; +var iter =function* () { + throw new Test262Error(); + following += 1; +}(); + + +var C = class { + static async *method([,]) { + + } +}; + +var method = C.method; + +assert.throws(Test262Error, function() { + method(iter); +}); + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); diff --git a/test/language/expressions/class/dstr-async-gen-meth-static-ary-ptrn-rest-id-elision-next-err.js b/test/language/expressions/class/dstr-async-gen-meth-static-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000..ec73abd858 --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-static-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision-next-err.case +// - src/dstr-binding/error/cls-expr-async-gen-meth-static.template +/*--- +description: Rest element following elision elements (static class expression async generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, 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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. + +---*/ +var iter = (function*() { throw new Test262Error(); })(); + + +var C = class { + static async *method([, ...x]) { + + } +}; + +var method = C.method; + +assert.throws(Test262Error, function() { + method(iter); +}); diff --git a/test/language/expressions/class/dstr-async-gen-meth-static-ary-ptrn-rest-id-iter-step-err.js b/test/language/expressions/class/dstr-async-gen-meth-static-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000..e0a0ef1aa8 --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-static-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case +// - src/dstr-binding/error/cls-expr-async-gen-meth-static.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (static class expression async generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, 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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + a. If iteratorRecord.[[done]] is false, + i. Let next be IteratorStep(iteratorRecord.[[iterator]]). + ii. If next is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(next). + +---*/ +var first = 0; +var second = 0; +var iter = function*() { + first += 1; + throw new Test262Error(); + second += 1; +}(); + + +var C = class { + static async *method([...x]) { + + } +}; + +var method = C.method; + +assert.throws(Test262Error, function() { + method(iter); +}); + +iter.next(); +assert.sameValue(first, 1); +assert.sameValue(second, 0, 'Iterator is closed following abrupt completion.'); diff --git a/test/language/expressions/class/dstr-async-gen-meth-static-ary-ptrn-rest-id-iter-val-err.js b/test/language/expressions/class/dstr-async-gen-meth-static-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000..50658691e2 --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-static-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-val-err.case +// - src/dstr-binding/error/cls-expr-async-gen-meth-static.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (static class expression async generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [Symbol.iterator, 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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + c. Let nextValue be IteratorValue(next). + d. If nextValue is an abrupt completion, set iteratorRecord.[[done]] to + true. + e. ReturnIfAbrupt(nextValue). + +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + + +var C = class { + static async *method([...x]) { + + } +}; + +var method = C.method; + +assert.throws(Test262Error, function() { + method(iter); +}); diff --git a/test/language/expressions/class/dstr-async-gen-meth-static-dflt-ary-init-iter-get-err.js b/test/language/expressions/class/dstr-async-gen-meth-static-dflt-ary-init-iter-get-err.js new file mode 100644 index 0000000000..f515a60b7f --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-static-dflt-ary-init-iter-get-err.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/cls-expr-async-gen-meth-static-dflt.template +/*--- +description: Abrupt completion returned by GetIterator (static class expression async generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [Symbol.iterator, 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). + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). + +---*/ +var iter = {}; +iter[Symbol.iterator] = function() { + throw new Test262Error(); +}; + + +var C = class { + static async *method([x] = iter) { + + } +}; + +var method = C.method; + +assert.throws(Test262Error, function() { + method(); +}); diff --git a/test/language/expressions/class/dstr-async-gen-meth-static-dflt-ary-ptrn-elem-ary-val-null.js b/test/language/expressions/class/dstr-async-gen-meth-static-dflt-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000..608dd0d613 --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-static-dflt-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-val-null.case +// - src/dstr-binding/error/cls-expr-async-gen-meth-static-dflt.template +/*--- +description: Nested array destructuring with a null value (static class expression async generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). +---*/ + + +var C = class { + static async *method([[x]] = [null]) { + + } +}; + +var method = C.method; + +assert.throws(TypeError, function() { + method(); +}); diff --git a/test/language/expressions/class/dstr-async-gen-meth-static-dflt-ary-ptrn-elem-id-init-throws.js b/test/language/expressions/class/dstr-async-gen-meth-static-dflt-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000..894b939e23 --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-static-dflt-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-throws.case +// - src/dstr-binding/error/cls-expr-async-gen-meth-static-dflt.template +/*--- +description: Destructuring initializer returns an abrupt completion (static class expression async generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ + + +var C = class { + static async *method([x = (function() { throw new Test262Error(); })()] = [undefined]) { + + } +}; + +var method = C.method; + +assert.throws(Test262Error, function() { + method(); +}); diff --git a/test/language/expressions/class/dstr-async-gen-meth-static-dflt-ary-ptrn-elem-id-init-unresolvable.js b/test/language/expressions/class/dstr-async-gen-meth-static-dflt-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000..b5fbca37de --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-static-dflt-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-unresolvable.case +// - src/dstr-binding/error/cls-expr-async-gen-meth-static-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (static class expression async generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + + +var C = class { + static async *method([ x = unresolvableReference ] = []) { + + } +}; + +var method = C.method; + +assert.throws(ReferenceError, function() { + method(); +}); diff --git a/test/language/expressions/class/dstr-async-gen-meth-static-dflt-ary-ptrn-elem-id-iter-step-err.js b/test/language/expressions/class/dstr-async-gen-meth-static-dflt-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000..fca13fdbab --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-static-dflt-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-step-err.case +// - src/dstr-binding/error/cls-expr-async-gen-meth-static-dflt.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (static class expression async generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). +---*/ +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + throw new Test262Error(); + } + }; +}; + + +var C = class { + static async *method([x] = g) { + + } +}; + +var method = C.method; + +assert.throws(Test262Error, function() { + method(); +}); diff --git a/test/language/expressions/class/dstr-async-gen-meth-static-dflt-ary-ptrn-elem-id-iter-val-err.js b/test/language/expressions/class/dstr-async-gen-meth-static-dflt-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000..969e933449 --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-static-dflt-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-err.case +// - src/dstr-binding/error/cls-expr-async-gen-meth-static-dflt.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (static class expression async generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(v). +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + + +var C = class { + static async *method([x] = g) { + + } +}; + +var method = C.method; + +assert.throws(Test262Error, function() { + method(); +}); diff --git a/test/language/expressions/class/dstr-async-gen-meth-static-dflt-ary-ptrn-elem-obj-val-null.js b/test/language/expressions/class/dstr-async-gen-meth-static-dflt-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000..acda92156c --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-static-dflt-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-null.case +// - src/dstr-binding/error/cls-expr-async-gen-meth-static-dflt.template +/*--- +description: Nested object destructuring with a null value (static class expression async generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + + +var C = class { + static async *method([{ x }] = [null]) { + + } +}; + +var method = C.method; + +assert.throws(TypeError, function() { + method(); +}); diff --git a/test/language/expressions/class/dstr-async-gen-meth-static-dflt-ary-ptrn-elem-obj-val-undef.js b/test/language/expressions/class/dstr-async-gen-meth-static-dflt-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000..5c2ea4b7a9 --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-static-dflt-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-undef.case +// - src/dstr-binding/error/cls-expr-async-gen-meth-static-dflt.template +/*--- +description: Nested object destructuring with a value of `undefined` (static class expression async generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + + +var C = class { + static async *method([{ x }] = []) { + + } +}; + +var method = C.method; + +assert.throws(TypeError, function() { + method(); +}); diff --git a/test/language/expressions/class/dstr-async-gen-meth-static-dflt-ary-ptrn-elision-step-err.js b/test/language/expressions/class/dstr-async-gen-meth-static-dflt-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000..0a066f54b7 --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-static-dflt-ary-ptrn-elision-step-err.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/cls-expr-async-gen-meth-static-dflt.template +/*--- +description: Elision advances iterator and forwards abrupt completions (static class expression async generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generator, 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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + +---*/ +var following = 0; +var iter =function* () { + throw new Test262Error(); + following += 1; +}(); + + +var C = class { + static async *method([,] = iter) { + + } +}; + +var method = C.method; + +assert.throws(Test262Error, function() { + method(); +}); + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); diff --git a/test/language/expressions/class/dstr-async-gen-meth-static-dflt-ary-ptrn-rest-id-elision-next-err.js b/test/language/expressions/class/dstr-async-gen-meth-static-dflt-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000..573338836c --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-static-dflt-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision-next-err.case +// - src/dstr-binding/error/cls-expr-async-gen-meth-static-dflt.template +/*--- +description: Rest element following elision elements (static class expression async generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, 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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. + +---*/ +var iter = (function*() { throw new Test262Error(); })(); + + +var C = class { + static async *method([, ...x] = iter) { + + } +}; + +var method = C.method; + +assert.throws(Test262Error, function() { + method(); +}); diff --git a/test/language/expressions/class/dstr-async-gen-meth-static-dflt-ary-ptrn-rest-id-iter-step-err.js b/test/language/expressions/class/dstr-async-gen-meth-static-dflt-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000..dd6341fafe --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-static-dflt-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case +// - src/dstr-binding/error/cls-expr-async-gen-meth-static-dflt.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (static class expression async generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, 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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + a. If iteratorRecord.[[done]] is false, + i. Let next be IteratorStep(iteratorRecord.[[iterator]]). + ii. If next is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(next). + +---*/ +var first = 0; +var second = 0; +var iter = function*() { + first += 1; + throw new Test262Error(); + second += 1; +}(); + + +var C = class { + static async *method([...x] = iter) { + + } +}; + +var method = C.method; + +assert.throws(Test262Error, function() { + method(); +}); + +iter.next(); +assert.sameValue(first, 1); +assert.sameValue(second, 0, 'Iterator is closed following abrupt completion.'); diff --git a/test/language/expressions/class/dstr-async-gen-meth-static-dflt-ary-ptrn-rest-id-iter-val-err.js b/test/language/expressions/class/dstr-async-gen-meth-static-dflt-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000..b696734f27 --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-static-dflt-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-val-err.case +// - src/dstr-binding/error/cls-expr-async-gen-meth-static-dflt.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (static class expression async generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [Symbol.iterator, 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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + c. Let nextValue be IteratorValue(next). + d. If nextValue is an abrupt completion, set iteratorRecord.[[done]] to + true. + e. ReturnIfAbrupt(nextValue). + +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + + +var C = class { + static async *method([...x] = iter) { + + } +}; + +var method = C.method; + +assert.throws(Test262Error, function() { + method(); +}); diff --git a/test/language/expressions/class/dstr-async-gen-meth-static-dflt-obj-init-null.js b/test/language/expressions/class/dstr-async-gen-meth-static-dflt-obj-init-null.js new file mode 100644 index 0000000000..8ed7991d3c --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-static-dflt-obj-init-null.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/cls-expr-async-gen-meth-static-dflt.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (static class expression async generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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). + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + + +var C = class { + static async *method({} = null) { + + } +}; + +var method = C.method; + +assert.throws(TypeError, function() { + method(); +}); diff --git a/test/language/expressions/class/dstr-async-gen-meth-static-dflt-obj-init-undefined.js b/test/language/expressions/class/dstr-async-gen-meth-static-dflt-obj-init-undefined.js new file mode 100644 index 0000000000..bbecf289ed --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-static-dflt-obj-init-undefined.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/cls-expr-async-gen-meth-static-dflt.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (static class expression async generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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). + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + + +var C = class { + static async *method({} = undefined) { + + } +}; + +var method = C.method; + +assert.throws(TypeError, function() { + method(); +}); diff --git a/test/language/expressions/class/dstr-async-gen-meth-static-dflt-obj-ptrn-id-get-value-err.js b/test/language/expressions/class/dstr-async-gen-meth-static-dflt-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000..1558df41b9 --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-static-dflt-obj-ptrn-id-get-value-err.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-get-value-err.case +// - src/dstr-binding/error/cls-expr-async-gen-meth-static-dflt.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (static class expression async generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. Let v be GetV(value, propertyName). + 5. ReturnIfAbrupt(v). +---*/ +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + + +var C = class { + static async *method({ poisoned } = poisonedProperty) { + + } +}; + +var method = C.method; + +assert.throws(Test262Error, function() { + method(); +}); diff --git a/test/language/expressions/class/dstr-async-gen-meth-static-dflt-obj-ptrn-id-init-throws.js b/test/language/expressions/class/dstr-async-gen-meth-static-dflt-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000..420ad9dc47 --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-static-dflt-obj-ptrn-id-init-throws.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/cls-expr-async-gen-meth-static-dflt.template +/*--- +description: Error thrown when evaluating the initializer (static class expression async generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + + +var C = class { + static async *method({ x = thrower() } = {}) { + + } +}; + +var method = C.method; + +assert.throws(Test262Error, function() { + method(); +}); diff --git a/test/language/expressions/class/dstr-async-gen-meth-static-dflt-obj-ptrn-id-init-unresolvable.js b/test/language/expressions/class/dstr-async-gen-meth-static-dflt-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000..09081f31a2 --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-static-dflt-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/cls-expr-async-gen-meth-static-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (static class expression async generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + + +var C = class { + static async *method({ x = unresolvableReference } = {}) { + + } +}; + +var method = C.method; + +assert.throws(ReferenceError, function() { + method(); +}); diff --git a/test/language/expressions/class/dstr-async-gen-meth-static-dflt-obj-ptrn-list-err.js b/test/language/expressions/class/dstr-async-gen-meth-static-dflt-obj-ptrn-list-err.js new file mode 100644 index 0000000000..75171b3283 --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-static-dflt-obj-ptrn-list-err.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/cls-expr-async-gen-meth-static-dflt.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (static class expression async generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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). + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPropertyList : BindingPropertyList , BindingProperty + + 1. Let status be the result of performing BindingInitialization for + BindingPropertyList using value and environment as arguments. + 2. ReturnIfAbrupt(status). +---*/ +var initCount = 0; +function thrower() { + throw new Test262Error(); +} + + +var C = class { + static async *method({ a, b = thrower(), c = ++initCount } = {}) { + + } +}; + +var method = C.method; + +assert.throws(Test262Error, function() { + method(); +}); + +assert.sameValue(initCount, 0); diff --git a/test/language/expressions/class/dstr-async-gen-meth-static-dflt-obj-ptrn-prop-ary-value-null.js b/test/language/expressions/class/dstr-async-gen-meth-static-dflt-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000..fdd43f869b --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-static-dflt-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-value-null.case +// - src/dstr-binding/error/cls-expr-async-gen-meth-static-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (static class expression async generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + + +var C = class { + static async *method({ w: [x, y, z] = [4, 5, 6] } = { w: null }) { + + } +}; + +var method = C.method; + +assert.throws(TypeError, function() { + method(); +}); diff --git a/test/language/expressions/class/dstr-async-gen-meth-static-dflt-obj-ptrn-prop-eval-err.js b/test/language/expressions/class/dstr-async-gen-meth-static-dflt-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000..8c3e91d7fb --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-static-dflt-obj-ptrn-prop-eval-err.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/cls-expr-async-gen-meth-static-dflt.template +/*--- +description: Evaluation of property name returns an abrupt completion (static class expression async generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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). + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingProperty : PropertyName : BindingElement + + 1. Let P be the result of evaluating PropertyName + 2. ReturnIfAbrupt(P). +---*/ +function thrower() { + throw new Test262Error(); +} + + +var C = class { + static async *method({ [thrower()]: x } = {}) { + + } +}; + +var method = C.method; + +assert.throws(Test262Error, function() { + method(); +}); diff --git a/test/language/expressions/class/dstr-async-gen-meth-static-dflt-obj-ptrn-prop-id-get-value-err.js b/test/language/expressions/class/dstr-async-gen-meth-static-dflt-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000..b8fa72d78e --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-static-dflt-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-get-value-err.case +// - src/dstr-binding/error/cls-expr-async-gen-meth-static-dflt.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (static class expression async generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. Let v be GetV(value, propertyName). + 2. ReturnIfAbrupt(v). +---*/ +var initEvalCount = 0; +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + + +var C = class { + static async *method({ poisoned: x = ++initEvalCount } = poisonedProperty) { + + } +}; + +var method = C.method; + +assert.throws(Test262Error, function() { + method(); +}); + +assert.sameValue(initEvalCount, 0); diff --git a/test/language/expressions/class/dstr-async-gen-meth-static-dflt-obj-ptrn-prop-id-init-throws.js b/test/language/expressions/class/dstr-async-gen-meth-static-dflt-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000..5a0e6226af --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-static-dflt-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-throws.case +// - src/dstr-binding/error/cls-expr-async-gen-meth-static-dflt.template +/*--- +description: Error thrown when evaluating the initializer (static class expression async generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + + +var C = class { + static async *method({ x: y = thrower() } = {}) { + + } +}; + +var method = C.method; + +assert.throws(Test262Error, function() { + method(); +}); diff --git a/test/language/expressions/class/dstr-async-gen-meth-static-dflt-obj-ptrn-prop-id-init-unresolvable.js b/test/language/expressions/class/dstr-async-gen-meth-static-dflt-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000..359810ccd7 --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-static-dflt-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-unresolvable.case +// - src/dstr-binding/error/cls-expr-async-gen-meth-static-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (static class expression async generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + + +var C = class { + static async *method({ x: y = unresolvableReference } = {}) { + + } +}; + +var method = C.method; + +assert.throws(ReferenceError, function() { + method(); +}); diff --git a/test/language/expressions/class/dstr-async-gen-meth-static-dflt-obj-ptrn-prop-obj-value-null.js b/test/language/expressions/class/dstr-async-gen-meth-static-dflt-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000..9a15cc4a25 --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-static-dflt-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-null.case +// - src/dstr-binding/error/cls-expr-async-gen-meth-static-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (static class expression async generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + + +var C = class { + static async *method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: null }) { + + } +}; + +var method = C.method; + +assert.throws(TypeError, function() { + method(); +}); diff --git a/test/language/expressions/class/dstr-async-gen-meth-static-dflt-obj-ptrn-prop-obj-value-undef.js b/test/language/expressions/class/dstr-async-gen-meth-static-dflt-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000..86c3f5bb28 --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-static-dflt-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-undef.case +// - src/dstr-binding/error/cls-expr-async-gen-meth-static-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (static class expression async generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + + +var C = class { + static async *method({ w: { x, y, z } = undefined } = { }) { + + } +}; + +var method = C.method; + +assert.throws(TypeError, function() { + method(); +}); diff --git a/test/language/expressions/class/dstr-async-gen-meth-static-obj-init-null.js b/test/language/expressions/class/dstr-async-gen-meth-static-obj-init-null.js new file mode 100644 index 0000000000..fe86f5c6fa --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-static-obj-init-null.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/cls-expr-async-gen-meth-static.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (static class expression async generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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). + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + + +var C = class { + static async *method({}) { + + } +}; + +var method = C.method; + +assert.throws(TypeError, function() { + method(null); +}); diff --git a/test/language/expressions/class/dstr-async-gen-meth-static-obj-init-undefined.js b/test/language/expressions/class/dstr-async-gen-meth-static-obj-init-undefined.js new file mode 100644 index 0000000000..c93d697b21 --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-static-obj-init-undefined.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/cls-expr-async-gen-meth-static.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (static class expression async generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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). + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + + +var C = class { + static async *method({}) { + + } +}; + +var method = C.method; + +assert.throws(TypeError, function() { + method(undefined); +}); diff --git a/test/language/expressions/class/dstr-async-gen-meth-static-obj-ptrn-id-get-value-err.js b/test/language/expressions/class/dstr-async-gen-meth-static-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000..837f12e310 --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-static-obj-ptrn-id-get-value-err.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-get-value-err.case +// - src/dstr-binding/error/cls-expr-async-gen-meth-static.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (static class expression async generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. Let v be GetV(value, propertyName). + 5. ReturnIfAbrupt(v). +---*/ +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + + +var C = class { + static async *method({ poisoned }) { + + } +}; + +var method = C.method; + +assert.throws(Test262Error, function() { + method(poisonedProperty); +}); diff --git a/test/language/expressions/class/dstr-async-gen-meth-static-obj-ptrn-id-init-throws.js b/test/language/expressions/class/dstr-async-gen-meth-static-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000..ff3998bdbc --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-static-obj-ptrn-id-init-throws.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/cls-expr-async-gen-meth-static.template +/*--- +description: Error thrown when evaluating the initializer (static class expression async generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + + +var C = class { + static async *method({ x = thrower() }) { + + } +}; + +var method = C.method; + +assert.throws(Test262Error, function() { + method({}); +}); diff --git a/test/language/expressions/class/dstr-async-gen-meth-static-obj-ptrn-id-init-unresolvable.js b/test/language/expressions/class/dstr-async-gen-meth-static-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000..ffb64d31ab --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-static-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/cls-expr-async-gen-meth-static.template +/*--- +description: Destructuring initializer is an unresolvable reference (static class expression async generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + + +var C = class { + static async *method({ x = unresolvableReference }) { + + } +}; + +var method = C.method; + +assert.throws(ReferenceError, function() { + method({}); +}); diff --git a/test/language/expressions/class/dstr-async-gen-meth-static-obj-ptrn-list-err.js b/test/language/expressions/class/dstr-async-gen-meth-static-obj-ptrn-list-err.js new file mode 100644 index 0000000000..dd9a170c63 --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-static-obj-ptrn-list-err.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/cls-expr-async-gen-meth-static.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (static class expression async generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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). + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPropertyList : BindingPropertyList , BindingProperty + + 1. Let status be the result of performing BindingInitialization for + BindingPropertyList using value and environment as arguments. + 2. ReturnIfAbrupt(status). +---*/ +var initCount = 0; +function thrower() { + throw new Test262Error(); +} + + +var C = class { + static async *method({ a, b = thrower(), c = ++initCount }) { + + } +}; + +var method = C.method; + +assert.throws(Test262Error, function() { + method({}); +}); + +assert.sameValue(initCount, 0); diff --git a/test/language/expressions/class/dstr-async-gen-meth-static-obj-ptrn-prop-ary-value-null.js b/test/language/expressions/class/dstr-async-gen-meth-static-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000..aa9720afca --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-static-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-value-null.case +// - src/dstr-binding/error/cls-expr-async-gen-meth-static.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (static class expression async generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + + +var C = class { + static async *method({ w: [x, y, z] = [4, 5, 6] }) { + + } +}; + +var method = C.method; + +assert.throws(TypeError, function() { + method({ w: null }); +}); diff --git a/test/language/expressions/class/dstr-async-gen-meth-static-obj-ptrn-prop-eval-err.js b/test/language/expressions/class/dstr-async-gen-meth-static-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000..940054339c --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-static-obj-ptrn-prop-eval-err.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/cls-expr-async-gen-meth-static.template +/*--- +description: Evaluation of property name returns an abrupt completion (static class expression async generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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). + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingProperty : PropertyName : BindingElement + + 1. Let P be the result of evaluating PropertyName + 2. ReturnIfAbrupt(P). +---*/ +function thrower() { + throw new Test262Error(); +} + + +var C = class { + static async *method({ [thrower()]: x }) { + + } +}; + +var method = C.method; + +assert.throws(Test262Error, function() { + method({}); +}); diff --git a/test/language/expressions/class/dstr-async-gen-meth-static-obj-ptrn-prop-id-get-value-err.js b/test/language/expressions/class/dstr-async-gen-meth-static-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000..2245d28737 --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-static-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-get-value-err.case +// - src/dstr-binding/error/cls-expr-async-gen-meth-static.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (static class expression async generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. Let v be GetV(value, propertyName). + 2. ReturnIfAbrupt(v). +---*/ +var initEvalCount = 0; +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + + +var C = class { + static async *method({ poisoned: x = ++initEvalCount }) { + + } +}; + +var method = C.method; + +assert.throws(Test262Error, function() { + method(poisonedProperty); +}); + +assert.sameValue(initEvalCount, 0); diff --git a/test/language/expressions/class/dstr-async-gen-meth-static-obj-ptrn-prop-id-init-throws.js b/test/language/expressions/class/dstr-async-gen-meth-static-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000..6d111099ee --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-static-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-throws.case +// - src/dstr-binding/error/cls-expr-async-gen-meth-static.template +/*--- +description: Error thrown when evaluating the initializer (static class expression async generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + + +var C = class { + static async *method({ x: y = thrower() }) { + + } +}; + +var method = C.method; + +assert.throws(Test262Error, function() { + method({}); +}); diff --git a/test/language/expressions/class/dstr-async-gen-meth-static-obj-ptrn-prop-id-init-unresolvable.js b/test/language/expressions/class/dstr-async-gen-meth-static-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000..68c91973f7 --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-static-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-unresolvable.case +// - src/dstr-binding/error/cls-expr-async-gen-meth-static.template +/*--- +description: Destructuring initializer is an unresolvable reference (static class expression async generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + + +var C = class { + static async *method({ x: y = unresolvableReference }) { + + } +}; + +var method = C.method; + +assert.throws(ReferenceError, function() { + method({}); +}); diff --git a/test/language/expressions/class/dstr-async-gen-meth-static-obj-ptrn-prop-obj-value-null.js b/test/language/expressions/class/dstr-async-gen-meth-static-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000..8290b87bca --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-static-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-null.case +// - src/dstr-binding/error/cls-expr-async-gen-meth-static.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (static class expression async generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + + +var C = class { + static async *method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) { + + } +}; + +var method = C.method; + +assert.throws(TypeError, function() { + method({ w: null }); +}); diff --git a/test/language/expressions/class/dstr-async-gen-meth-static-obj-ptrn-prop-obj-value-undef.js b/test/language/expressions/class/dstr-async-gen-meth-static-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000..9be78da0c0 --- /dev/null +++ b/test/language/expressions/class/dstr-async-gen-meth-static-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-undef.case +// - src/dstr-binding/error/cls-expr-async-gen-meth-static.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (static class expression async generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + + +var C = class { + static async *method({ w: { x, y, z } = undefined }) { + + } +}; + +var method = C.method; + +assert.throws(TypeError, function() { + method({ }); +}); diff --git a/test/language/expressions/object/dstr-async-gen-meth-ary-init-iter-get-err.js b/test/language/expressions/object/dstr-async-gen-meth-ary-init-iter-get-err.js new file mode 100644 index 0000000000..3a2cf7eaee --- /dev/null +++ b/test/language/expressions/object/dstr-async-gen-meth-ary-init-iter-get-err.js @@ -0,0 +1,45 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/async-gen-meth.template +/*--- +description: Abrupt completion returned by GetIterator (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [Symbol.iterator, 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). + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). + +---*/ +var iter = {}; +iter[Symbol.iterator] = function() { + throw new Test262Error(); +}; + + +var obj = { + async *method([x]) { + + } +}; + +assert.throws(Test262Error, function() { + obj.method(iter); +}); diff --git a/test/language/expressions/object/dstr-async-gen-meth-ary-ptrn-elem-ary-val-null.js b/test/language/expressions/object/dstr-async-gen-meth-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000..564267370b --- /dev/null +++ b/test/language/expressions/object/dstr-async-gen-meth-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-val-null.case +// - src/dstr-binding/error/async-gen-meth.template +/*--- +description: Nested array destructuring with a null value (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). +---*/ + + +var obj = { + async *method([[x]]) { + + } +}; + +assert.throws(TypeError, function() { + obj.method([null]); +}); diff --git a/test/language/expressions/object/dstr-async-gen-meth-ary-ptrn-elem-id-init-throws.js b/test/language/expressions/object/dstr-async-gen-meth-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000..b0c83d014e --- /dev/null +++ b/test/language/expressions/object/dstr-async-gen-meth-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-throws.case +// - src/dstr-binding/error/async-gen-meth.template +/*--- +description: Destructuring initializer returns an abrupt completion (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ + + +var obj = { + async *method([x = (function() { throw new Test262Error(); })()]) { + + } +}; + +assert.throws(Test262Error, function() { + obj.method([undefined]); +}); diff --git a/test/language/expressions/object/dstr-async-gen-meth-ary-ptrn-elem-id-init-unresolvable.js b/test/language/expressions/object/dstr-async-gen-meth-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000..043f9ba936 --- /dev/null +++ b/test/language/expressions/object/dstr-async-gen-meth-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-unresolvable.case +// - src/dstr-binding/error/async-gen-meth.template +/*--- +description: Destructuring initializer is an unresolvable reference (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + + +var obj = { + async *method([ x = unresolvableReference ]) { + + } +}; + +assert.throws(ReferenceError, function() { + obj.method([]); +}); diff --git a/test/language/expressions/object/dstr-async-gen-meth-ary-ptrn-elem-id-iter-step-err.js b/test/language/expressions/object/dstr-async-gen-meth-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000..e3a210febf --- /dev/null +++ b/test/language/expressions/object/dstr-async-gen-meth-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-step-err.case +// - src/dstr-binding/error/async-gen-meth.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). +---*/ +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + throw new Test262Error(); + } + }; +}; + + +var obj = { + async *method([x]) { + + } +}; + +assert.throws(Test262Error, function() { + obj.method(g); +}); diff --git a/test/language/expressions/object/dstr-async-gen-meth-ary-ptrn-elem-id-iter-val-err.js b/test/language/expressions/object/dstr-async-gen-meth-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000..ce4e002647 --- /dev/null +++ b/test/language/expressions/object/dstr-async-gen-meth-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-err.case +// - src/dstr-binding/error/async-gen-meth.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(v). +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + + +var obj = { + async *method([x]) { + + } +}; + +assert.throws(Test262Error, function() { + obj.method(g); +}); diff --git a/test/language/expressions/object/dstr-async-gen-meth-ary-ptrn-elem-obj-val-null.js b/test/language/expressions/object/dstr-async-gen-meth-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000..8914ca873b --- /dev/null +++ b/test/language/expressions/object/dstr-async-gen-meth-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-null.case +// - src/dstr-binding/error/async-gen-meth.template +/*--- +description: Nested object destructuring with a null value (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + + +var obj = { + async *method([{ x }]) { + + } +}; + +assert.throws(TypeError, function() { + obj.method([null]); +}); diff --git a/test/language/expressions/object/dstr-async-gen-meth-ary-ptrn-elem-obj-val-undef.js b/test/language/expressions/object/dstr-async-gen-meth-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000..c0345f3557 --- /dev/null +++ b/test/language/expressions/object/dstr-async-gen-meth-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-undef.case +// - src/dstr-binding/error/async-gen-meth.template +/*--- +description: Nested object destructuring with a value of `undefined` (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + + +var obj = { + async *method([{ x }]) { + + } +}; + +assert.throws(TypeError, function() { + obj.method([]); +}); diff --git a/test/language/expressions/object/dstr-async-gen-meth-ary-ptrn-elision-step-err.js b/test/language/expressions/object/dstr-async-gen-meth-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000..c8a474b52b --- /dev/null +++ b/test/language/expressions/object/dstr-async-gen-meth-ary-ptrn-elision-step-err.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/async-gen-meth.template +/*--- +description: Elision advances iterator and forwards abrupt completions (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [generator, 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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + +---*/ +var following = 0; +var iter =function* () { + throw new Test262Error(); + following += 1; +}(); + + +var obj = { + async *method([,]) { + + } +}; + +assert.throws(Test262Error, function() { + obj.method(iter); +}); + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); diff --git a/test/language/expressions/object/dstr-async-gen-meth-ary-ptrn-rest-id-elision-next-err.js b/test/language/expressions/object/dstr-async-gen-meth-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000..44b321b3be --- /dev/null +++ b/test/language/expressions/object/dstr-async-gen-meth-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,45 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision-next-err.case +// - src/dstr-binding/error/async-gen-meth.template +/*--- +description: Rest element following elision elements (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [generators, 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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. + +---*/ +var iter = (function*() { throw new Test262Error(); })(); + + +var obj = { + async *method([, ...x]) { + + } +}; + +assert.throws(Test262Error, function() { + obj.method(iter); +}); diff --git a/test/language/expressions/object/dstr-async-gen-meth-ary-ptrn-rest-id-iter-step-err.js b/test/language/expressions/object/dstr-async-gen-meth-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000..70b8dc10a2 --- /dev/null +++ b/test/language/expressions/object/dstr-async-gen-meth-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case +// - src/dstr-binding/error/async-gen-meth.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [generators, 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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + a. If iteratorRecord.[[done]] is false, + i. Let next be IteratorStep(iteratorRecord.[[iterator]]). + ii. If next is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(next). + +---*/ +var first = 0; +var second = 0; +var iter = function*() { + first += 1; + throw new Test262Error(); + second += 1; +}(); + + +var obj = { + async *method([...x]) { + + } +}; + +assert.throws(Test262Error, function() { + obj.method(iter); +}); + +iter.next(); +assert.sameValue(first, 1); +assert.sameValue(second, 0, 'Iterator is closed following abrupt completion.'); diff --git a/test/language/expressions/object/dstr-async-gen-meth-ary-ptrn-rest-id-iter-val-err.js b/test/language/expressions/object/dstr-async-gen-meth-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000..ec03a43a43 --- /dev/null +++ b/test/language/expressions/object/dstr-async-gen-meth-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-val-err.case +// - src/dstr-binding/error/async-gen-meth.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [Symbol.iterator, 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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + c. Let nextValue be IteratorValue(next). + d. If nextValue is an abrupt completion, set iteratorRecord.[[done]] to + true. + e. ReturnIfAbrupt(nextValue). + +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + + +var obj = { + async *method([...x]) { + + } +}; + +assert.throws(Test262Error, function() { + obj.method(iter); +}); diff --git a/test/language/expressions/object/dstr-async-gen-meth-dflt-ary-init-iter-get-err.js b/test/language/expressions/object/dstr-async-gen-meth-dflt-ary-init-iter-get-err.js new file mode 100644 index 0000000000..64c5a314fc --- /dev/null +++ b/test/language/expressions/object/dstr-async-gen-meth-dflt-ary-init-iter-get-err.js @@ -0,0 +1,45 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/async-gen-method-dflt.template +/*--- +description: Abrupt completion returned by GetIterator (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [Symbol.iterator, 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). + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). + +---*/ +var iter = {}; +iter[Symbol.iterator] = function() { + throw new Test262Error(); +}; + + +var obj = { + async *method([x] = iter) { + + } +}; + +assert.throws(Test262Error, function() { + obj.method(); +}); diff --git a/test/language/expressions/object/dstr-async-gen-meth-dflt-ary-ptrn-elem-ary-val-null.js b/test/language/expressions/object/dstr-async-gen-meth-dflt-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000..cff1d2bd38 --- /dev/null +++ b/test/language/expressions/object/dstr-async-gen-meth-dflt-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-val-null.case +// - src/dstr-binding/error/async-gen-method-dflt.template +/*--- +description: Nested array destructuring with a null value (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). +---*/ + + +var obj = { + async *method([[x]] = [null]) { + + } +}; + +assert.throws(TypeError, function() { + obj.method(); +}); diff --git a/test/language/expressions/object/dstr-async-gen-meth-dflt-ary-ptrn-elem-id-init-throws.js b/test/language/expressions/object/dstr-async-gen-meth-dflt-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000..ec6ee54cb2 --- /dev/null +++ b/test/language/expressions/object/dstr-async-gen-meth-dflt-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-throws.case +// - src/dstr-binding/error/async-gen-method-dflt.template +/*--- +description: Destructuring initializer returns an abrupt completion (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ + + +var obj = { + async *method([x = (function() { throw new Test262Error(); })()] = [undefined]) { + + } +}; + +assert.throws(Test262Error, function() { + obj.method(); +}); diff --git a/test/language/expressions/object/dstr-async-gen-meth-dflt-ary-ptrn-elem-id-init-unresolvable.js b/test/language/expressions/object/dstr-async-gen-meth-dflt-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000..ca2727fba2 --- /dev/null +++ b/test/language/expressions/object/dstr-async-gen-meth-dflt-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-unresolvable.case +// - src/dstr-binding/error/async-gen-method-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + + +var obj = { + async *method([ x = unresolvableReference ] = []) { + + } +}; + +assert.throws(ReferenceError, function() { + obj.method(); +}); diff --git a/test/language/expressions/object/dstr-async-gen-meth-dflt-ary-ptrn-elem-id-iter-step-err.js b/test/language/expressions/object/dstr-async-gen-meth-dflt-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000..e29e7c596e --- /dev/null +++ b/test/language/expressions/object/dstr-async-gen-meth-dflt-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-step-err.case +// - src/dstr-binding/error/async-gen-method-dflt.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). +---*/ +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + throw new Test262Error(); + } + }; +}; + + +var obj = { + async *method([x] = g) { + + } +}; + +assert.throws(Test262Error, function() { + obj.method(); +}); diff --git a/test/language/expressions/object/dstr-async-gen-meth-dflt-ary-ptrn-elem-id-iter-val-err.js b/test/language/expressions/object/dstr-async-gen-meth-dflt-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000..08c8dfda01 --- /dev/null +++ b/test/language/expressions/object/dstr-async-gen-meth-dflt-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-err.case +// - src/dstr-binding/error/async-gen-method-dflt.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(v). +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + + +var obj = { + async *method([x] = g) { + + } +}; + +assert.throws(Test262Error, function() { + obj.method(); +}); diff --git a/test/language/expressions/object/dstr-async-gen-meth-dflt-ary-ptrn-elem-obj-val-null.js b/test/language/expressions/object/dstr-async-gen-meth-dflt-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000..568ea84576 --- /dev/null +++ b/test/language/expressions/object/dstr-async-gen-meth-dflt-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-null.case +// - src/dstr-binding/error/async-gen-method-dflt.template +/*--- +description: Nested object destructuring with a null value (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + + +var obj = { + async *method([{ x }] = [null]) { + + } +}; + +assert.throws(TypeError, function() { + obj.method(); +}); diff --git a/test/language/expressions/object/dstr-async-gen-meth-dflt-ary-ptrn-elem-obj-val-undef.js b/test/language/expressions/object/dstr-async-gen-meth-dflt-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000..27edc39150 --- /dev/null +++ b/test/language/expressions/object/dstr-async-gen-meth-dflt-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-undef.case +// - src/dstr-binding/error/async-gen-method-dflt.template +/*--- +description: Nested object destructuring with a value of `undefined` (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + + +var obj = { + async *method([{ x }] = []) { + + } +}; + +assert.throws(TypeError, function() { + obj.method(); +}); diff --git a/test/language/expressions/object/dstr-async-gen-meth-dflt-ary-ptrn-elision-step-err.js b/test/language/expressions/object/dstr-async-gen-meth-dflt-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000..cb2a488f24 --- /dev/null +++ b/test/language/expressions/object/dstr-async-gen-meth-dflt-ary-ptrn-elision-step-err.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/async-gen-method-dflt.template +/*--- +description: Elision advances iterator and forwards abrupt completions (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [generator, 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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + +---*/ +var following = 0; +var iter =function* () { + throw new Test262Error(); + following += 1; +}(); + + +var obj = { + async *method([,] = iter) { + + } +}; + +assert.throws(Test262Error, function() { + obj.method(); +}); + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); diff --git a/test/language/expressions/object/dstr-async-gen-meth-dflt-ary-ptrn-rest-id-elision-next-err.js b/test/language/expressions/object/dstr-async-gen-meth-dflt-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000..98faa06f2f --- /dev/null +++ b/test/language/expressions/object/dstr-async-gen-meth-dflt-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,45 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision-next-err.case +// - src/dstr-binding/error/async-gen-method-dflt.template +/*--- +description: Rest element following elision elements (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [generators, 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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. + +---*/ +var iter = (function*() { throw new Test262Error(); })(); + + +var obj = { + async *method([, ...x] = iter) { + + } +}; + +assert.throws(Test262Error, function() { + obj.method(); +}); diff --git a/test/language/expressions/object/dstr-async-gen-meth-dflt-ary-ptrn-rest-id-iter-step-err.js b/test/language/expressions/object/dstr-async-gen-meth-dflt-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000..839345caf9 --- /dev/null +++ b/test/language/expressions/object/dstr-async-gen-meth-dflt-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case +// - src/dstr-binding/error/async-gen-method-dflt.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [generators, 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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + a. If iteratorRecord.[[done]] is false, + i. Let next be IteratorStep(iteratorRecord.[[iterator]]). + ii. If next is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(next). + +---*/ +var first = 0; +var second = 0; +var iter = function*() { + first += 1; + throw new Test262Error(); + second += 1; +}(); + + +var obj = { + async *method([...x] = iter) { + + } +}; + +assert.throws(Test262Error, function() { + obj.method(); +}); + +iter.next(); +assert.sameValue(first, 1); +assert.sameValue(second, 0, 'Iterator is closed following abrupt completion.'); diff --git a/test/language/expressions/object/dstr-async-gen-meth-dflt-ary-ptrn-rest-id-iter-val-err.js b/test/language/expressions/object/dstr-async-gen-meth-dflt-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000..c271e75788 --- /dev/null +++ b/test/language/expressions/object/dstr-async-gen-meth-dflt-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-val-err.case +// - src/dstr-binding/error/async-gen-method-dflt.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [Symbol.iterator, 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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + c. Let nextValue be IteratorValue(next). + d. If nextValue is an abrupt completion, set iteratorRecord.[[done]] to + true. + e. ReturnIfAbrupt(nextValue). + +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + + +var obj = { + async *method([...x] = iter) { + + } +}; + +assert.throws(Test262Error, function() { + obj.method(); +}); diff --git a/test/language/expressions/object/dstr-async-gen-meth-dflt-obj-init-null.js b/test/language/expressions/object/dstr-async-gen-meth-dflt-obj-init-null.js new file mode 100644 index 0000000000..613c5f9644 --- /dev/null +++ b/test/language/expressions/object/dstr-async-gen-meth-dflt-obj-init-null.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/async-gen-method-dflt.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [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). + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + + +var obj = { + async *method({} = null) { + + } +}; + +assert.throws(TypeError, function() { + obj.method(); +}); diff --git a/test/language/expressions/object/dstr-async-gen-meth-dflt-obj-init-undefined.js b/test/language/expressions/object/dstr-async-gen-meth-dflt-obj-init-undefined.js new file mode 100644 index 0000000000..21c341f5f0 --- /dev/null +++ b/test/language/expressions/object/dstr-async-gen-meth-dflt-obj-init-undefined.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/async-gen-method-dflt.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [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). + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + + +var obj = { + async *method({} = undefined) { + + } +}; + +assert.throws(TypeError, function() { + obj.method(); +}); diff --git a/test/language/expressions/object/dstr-async-gen-meth-dflt-obj-ptrn-id-get-value-err.js b/test/language/expressions/object/dstr-async-gen-meth-dflt-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000..d248d7da2c --- /dev/null +++ b/test/language/expressions/object/dstr-async-gen-meth-dflt-obj-ptrn-id-get-value-err.js @@ -0,0 +1,46 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-get-value-err.case +// - src/dstr-binding/error/async-gen-method-dflt.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [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). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. Let v be GetV(value, propertyName). + 5. ReturnIfAbrupt(v). +---*/ +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + + +var obj = { + async *method({ poisoned } = poisonedProperty) { + + } +}; + +assert.throws(Test262Error, function() { + obj.method(); +}); diff --git a/test/language/expressions/object/dstr-async-gen-meth-dflt-obj-ptrn-id-init-throws.js b/test/language/expressions/object/dstr-async-gen-meth-dflt-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000..82de889bb7 --- /dev/null +++ b/test/language/expressions/object/dstr-async-gen-meth-dflt-obj-ptrn-id-init-throws.js @@ -0,0 +1,46 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/async-gen-method-dflt.template +/*--- +description: Error thrown when evaluating the initializer (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [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). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + + +var obj = { + async *method({ x = thrower() } = {}) { + + } +}; + +assert.throws(Test262Error, function() { + obj.method(); +}); diff --git a/test/language/expressions/object/dstr-async-gen-meth-dflt-obj-ptrn-id-init-unresolvable.js b/test/language/expressions/object/dstr-async-gen-meth-dflt-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000..13b49715da --- /dev/null +++ b/test/language/expressions/object/dstr-async-gen-meth-dflt-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/async-gen-method-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [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). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + + +var obj = { + async *method({ x = unresolvableReference } = {}) { + + } +}; + +assert.throws(ReferenceError, function() { + obj.method(); +}); diff --git a/test/language/expressions/object/dstr-async-gen-meth-dflt-obj-ptrn-list-err.js b/test/language/expressions/object/dstr-async-gen-meth-dflt-obj-ptrn-list-err.js new file mode 100644 index 0000000000..06d36cbc9d --- /dev/null +++ b/test/language/expressions/object/dstr-async-gen-meth-dflt-obj-ptrn-list-err.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/async-gen-method-dflt.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [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). + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPropertyList : BindingPropertyList , BindingProperty + + 1. Let status be the result of performing BindingInitialization for + BindingPropertyList using value and environment as arguments. + 2. ReturnIfAbrupt(status). +---*/ +var initCount = 0; +function thrower() { + throw new Test262Error(); +} + + +var obj = { + async *method({ a, b = thrower(), c = ++initCount } = {}) { + + } +}; + +assert.throws(Test262Error, function() { + obj.method(); +}); + +assert.sameValue(initCount, 0); diff --git a/test/language/expressions/object/dstr-async-gen-meth-dflt-obj-ptrn-prop-ary-value-null.js b/test/language/expressions/object/dstr-async-gen-meth-dflt-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000..a28fd46489 --- /dev/null +++ b/test/language/expressions/object/dstr-async-gen-meth-dflt-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-value-null.case +// - src/dstr-binding/error/async-gen-method-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [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). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + + +var obj = { + async *method({ w: [x, y, z] = [4, 5, 6] } = { w: null }) { + + } +}; + +assert.throws(TypeError, function() { + obj.method(); +}); diff --git a/test/language/expressions/object/dstr-async-gen-meth-dflt-obj-ptrn-prop-eval-err.js b/test/language/expressions/object/dstr-async-gen-meth-dflt-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000..bb3c56222b --- /dev/null +++ b/test/language/expressions/object/dstr-async-gen-meth-dflt-obj-ptrn-prop-eval-err.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/async-gen-method-dflt.template +/*--- +description: Evaluation of property name returns an abrupt completion (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [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). + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingProperty : PropertyName : BindingElement + + 1. Let P be the result of evaluating PropertyName + 2. ReturnIfAbrupt(P). +---*/ +function thrower() { + throw new Test262Error(); +} + + +var obj = { + async *method({ [thrower()]: x } = {}) { + + } +}; + +assert.throws(Test262Error, function() { + obj.method(); +}); diff --git a/test/language/expressions/object/dstr-async-gen-meth-dflt-obj-ptrn-prop-id-get-value-err.js b/test/language/expressions/object/dstr-async-gen-meth-dflt-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000..2e8ee7b940 --- /dev/null +++ b/test/language/expressions/object/dstr-async-gen-meth-dflt-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-get-value-err.case +// - src/dstr-binding/error/async-gen-method-dflt.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [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). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. Let v be GetV(value, propertyName). + 2. ReturnIfAbrupt(v). +---*/ +var initEvalCount = 0; +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + + +var obj = { + async *method({ poisoned: x = ++initEvalCount } = poisonedProperty) { + + } +}; + +assert.throws(Test262Error, function() { + obj.method(); +}); + +assert.sameValue(initEvalCount, 0); diff --git a/test/language/expressions/object/dstr-async-gen-meth-dflt-obj-ptrn-prop-id-init-throws.js b/test/language/expressions/object/dstr-async-gen-meth-dflt-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000..c8d7295c63 --- /dev/null +++ b/test/language/expressions/object/dstr-async-gen-meth-dflt-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,46 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-throws.case +// - src/dstr-binding/error/async-gen-method-dflt.template +/*--- +description: Error thrown when evaluating the initializer (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [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). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + + +var obj = { + async *method({ x: y = thrower() } = {}) { + + } +}; + +assert.throws(Test262Error, function() { + obj.method(); +}); diff --git a/test/language/expressions/object/dstr-async-gen-meth-dflt-obj-ptrn-prop-id-init-unresolvable.js b/test/language/expressions/object/dstr-async-gen-meth-dflt-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000..a07e0cba47 --- /dev/null +++ b/test/language/expressions/object/dstr-async-gen-meth-dflt-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-unresolvable.case +// - src/dstr-binding/error/async-gen-method-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [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). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + + +var obj = { + async *method({ x: y = unresolvableReference } = {}) { + + } +}; + +assert.throws(ReferenceError, function() { + obj.method(); +}); diff --git a/test/language/expressions/object/dstr-async-gen-meth-dflt-obj-ptrn-prop-obj-value-null.js b/test/language/expressions/object/dstr-async-gen-meth-dflt-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000..8c8c2e1af1 --- /dev/null +++ b/test/language/expressions/object/dstr-async-gen-meth-dflt-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-null.case +// - src/dstr-binding/error/async-gen-method-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [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). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + + +var obj = { + async *method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: null }) { + + } +}; + +assert.throws(TypeError, function() { + obj.method(); +}); diff --git a/test/language/expressions/object/dstr-async-gen-meth-dflt-obj-ptrn-prop-obj-value-undef.js b/test/language/expressions/object/dstr-async-gen-meth-dflt-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000..e566fcb0c3 --- /dev/null +++ b/test/language/expressions/object/dstr-async-gen-meth-dflt-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-undef.case +// - src/dstr-binding/error/async-gen-method-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [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). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + + +var obj = { + async *method({ w: { x, y, z } = undefined } = { }) { + + } +}; + +assert.throws(TypeError, function() { + obj.method(); +}); diff --git a/test/language/expressions/object/dstr-async-gen-meth-obj-init-null.js b/test/language/expressions/object/dstr-async-gen-meth-obj-init-null.js new file mode 100644 index 0000000000..2f8493ecb7 --- /dev/null +++ b/test/language/expressions/object/dstr-async-gen-meth-obj-init-null.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/async-gen-meth.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [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). + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + + +var obj = { + async *method({}) { + + } +}; + +assert.throws(TypeError, function() { + obj.method(null); +}); diff --git a/test/language/expressions/object/dstr-async-gen-meth-obj-init-undefined.js b/test/language/expressions/object/dstr-async-gen-meth-obj-init-undefined.js new file mode 100644 index 0000000000..1f370ff1e9 --- /dev/null +++ b/test/language/expressions/object/dstr-async-gen-meth-obj-init-undefined.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/async-gen-meth.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [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). + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + + +var obj = { + async *method({}) { + + } +}; + +assert.throws(TypeError, function() { + obj.method(undefined); +}); diff --git a/test/language/expressions/object/dstr-async-gen-meth-obj-ptrn-id-get-value-err.js b/test/language/expressions/object/dstr-async-gen-meth-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000..443d1b160d --- /dev/null +++ b/test/language/expressions/object/dstr-async-gen-meth-obj-ptrn-id-get-value-err.js @@ -0,0 +1,46 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-get-value-err.case +// - src/dstr-binding/error/async-gen-meth.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [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). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. Let v be GetV(value, propertyName). + 5. ReturnIfAbrupt(v). +---*/ +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + + +var obj = { + async *method({ poisoned }) { + + } +}; + +assert.throws(Test262Error, function() { + obj.method(poisonedProperty); +}); diff --git a/test/language/expressions/object/dstr-async-gen-meth-obj-ptrn-id-init-throws.js b/test/language/expressions/object/dstr-async-gen-meth-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000..751c3e25bb --- /dev/null +++ b/test/language/expressions/object/dstr-async-gen-meth-obj-ptrn-id-init-throws.js @@ -0,0 +1,46 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/async-gen-meth.template +/*--- +description: Error thrown when evaluating the initializer (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [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). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + + +var obj = { + async *method({ x = thrower() }) { + + } +}; + +assert.throws(Test262Error, function() { + obj.method({}); +}); diff --git a/test/language/expressions/object/dstr-async-gen-meth-obj-ptrn-id-init-unresolvable.js b/test/language/expressions/object/dstr-async-gen-meth-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000..0b8050b6f6 --- /dev/null +++ b/test/language/expressions/object/dstr-async-gen-meth-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/async-gen-meth.template +/*--- +description: Destructuring initializer is an unresolvable reference (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [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). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + + +var obj = { + async *method({ x = unresolvableReference }) { + + } +}; + +assert.throws(ReferenceError, function() { + obj.method({}); +}); diff --git a/test/language/expressions/object/dstr-async-gen-meth-obj-ptrn-list-err.js b/test/language/expressions/object/dstr-async-gen-meth-obj-ptrn-list-err.js new file mode 100644 index 0000000000..de462f8d1a --- /dev/null +++ b/test/language/expressions/object/dstr-async-gen-meth-obj-ptrn-list-err.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/async-gen-meth.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [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). + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPropertyList : BindingPropertyList , BindingProperty + + 1. Let status be the result of performing BindingInitialization for + BindingPropertyList using value and environment as arguments. + 2. ReturnIfAbrupt(status). +---*/ +var initCount = 0; +function thrower() { + throw new Test262Error(); +} + + +var obj = { + async *method({ a, b = thrower(), c = ++initCount }) { + + } +}; + +assert.throws(Test262Error, function() { + obj.method({}); +}); + +assert.sameValue(initCount, 0); diff --git a/test/language/expressions/object/dstr-async-gen-meth-obj-ptrn-prop-ary-value-null.js b/test/language/expressions/object/dstr-async-gen-meth-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000..5e1ef9da36 --- /dev/null +++ b/test/language/expressions/object/dstr-async-gen-meth-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-value-null.case +// - src/dstr-binding/error/async-gen-meth.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [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). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + + +var obj = { + async *method({ w: [x, y, z] = [4, 5, 6] }) { + + } +}; + +assert.throws(TypeError, function() { + obj.method({ w: null }); +}); diff --git a/test/language/expressions/object/dstr-async-gen-meth-obj-ptrn-prop-eval-err.js b/test/language/expressions/object/dstr-async-gen-meth-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000..11272a1023 --- /dev/null +++ b/test/language/expressions/object/dstr-async-gen-meth-obj-ptrn-prop-eval-err.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/async-gen-meth.template +/*--- +description: Evaluation of property name returns an abrupt completion (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [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). + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingProperty : PropertyName : BindingElement + + 1. Let P be the result of evaluating PropertyName + 2. ReturnIfAbrupt(P). +---*/ +function thrower() { + throw new Test262Error(); +} + + +var obj = { + async *method({ [thrower()]: x }) { + + } +}; + +assert.throws(Test262Error, function() { + obj.method({}); +}); diff --git a/test/language/expressions/object/dstr-async-gen-meth-obj-ptrn-prop-id-get-value-err.js b/test/language/expressions/object/dstr-async-gen-meth-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000..90b1d8a7f0 --- /dev/null +++ b/test/language/expressions/object/dstr-async-gen-meth-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-get-value-err.case +// - src/dstr-binding/error/async-gen-meth.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [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). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. Let v be GetV(value, propertyName). + 2. ReturnIfAbrupt(v). +---*/ +var initEvalCount = 0; +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + + +var obj = { + async *method({ poisoned: x = ++initEvalCount }) { + + } +}; + +assert.throws(Test262Error, function() { + obj.method(poisonedProperty); +}); + +assert.sameValue(initEvalCount, 0); diff --git a/test/language/expressions/object/dstr-async-gen-meth-obj-ptrn-prop-id-init-throws.js b/test/language/expressions/object/dstr-async-gen-meth-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000..971b8e3f1f --- /dev/null +++ b/test/language/expressions/object/dstr-async-gen-meth-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,46 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-throws.case +// - src/dstr-binding/error/async-gen-meth.template +/*--- +description: Error thrown when evaluating the initializer (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [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). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + + +var obj = { + async *method({ x: y = thrower() }) { + + } +}; + +assert.throws(Test262Error, function() { + obj.method({}); +}); diff --git a/test/language/expressions/object/dstr-async-gen-meth-obj-ptrn-prop-id-init-unresolvable.js b/test/language/expressions/object/dstr-async-gen-meth-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000..3400405f3e --- /dev/null +++ b/test/language/expressions/object/dstr-async-gen-meth-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-unresolvable.case +// - src/dstr-binding/error/async-gen-meth.template +/*--- +description: Destructuring initializer is an unresolvable reference (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [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). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + + +var obj = { + async *method({ x: y = unresolvableReference }) { + + } +}; + +assert.throws(ReferenceError, function() { + obj.method({}); +}); diff --git a/test/language/expressions/object/dstr-async-gen-meth-obj-ptrn-prop-obj-value-null.js b/test/language/expressions/object/dstr-async-gen-meth-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000..ce5a9bf480 --- /dev/null +++ b/test/language/expressions/object/dstr-async-gen-meth-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-null.case +// - src/dstr-binding/error/async-gen-meth.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [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). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + + +var obj = { + async *method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) { + + } +}; + +assert.throws(TypeError, function() { + obj.method({ w: null }); +}); diff --git a/test/language/expressions/object/dstr-async-gen-meth-obj-ptrn-prop-obj-value-undef.js b/test/language/expressions/object/dstr-async-gen-meth-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000..dbbf2b8d31 --- /dev/null +++ b/test/language/expressions/object/dstr-async-gen-meth-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-undef.case +// - src/dstr-binding/error/async-gen-meth.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [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). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + + +var obj = { + async *method({ w: { x, y, z } = undefined }) { + + } +}; + +assert.throws(TypeError, function() { + obj.method({ }); +}); diff --git a/test/language/statements/async-generator/dstr-ary-init-iter-get-err.js b/test/language/statements/async-generator/dstr-ary-init-iter-get-err.js new file mode 100644 index 0000000000..bbebb279e3 --- /dev/null +++ b/test/language/statements/async-generator/dstr-ary-init-iter-get-err.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/async-gen-func-decl.template +/*--- +description: Abrupt completion returned by GetIterator (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [Symbol.iterator, async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). + +---*/ +var iter = {}; +iter[Symbol.iterator] = function() { + throw new Test262Error(); +}; + + +async function* f([x]) { + +}; + +assert.throws(Test262Error, function() { + f(iter); +}); diff --git a/test/language/statements/async-generator/dstr-ary-ptrn-elem-ary-val-null.js b/test/language/statements/async-generator/dstr-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000..6e90281a3d --- /dev/null +++ b/test/language/statements/async-generator/dstr-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,45 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-val-null.case +// - src/dstr-binding/error/async-gen-func-decl.template +/*--- +description: Nested array destructuring with a null value (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). +---*/ + + +async function* f([[x]]) { + +}; + +assert.throws(TypeError, function() { + f([null]); +}); diff --git a/test/language/statements/async-generator/dstr-ary-ptrn-elem-id-init-throws.js b/test/language/statements/async-generator/dstr-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000..5efc4499d8 --- /dev/null +++ b/test/language/statements/async-generator/dstr-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-throws.case +// - src/dstr-binding/error/async-gen-func-decl.template +/*--- +description: Destructuring initializer returns an abrupt completion (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ + + +async function* f([x = (function() { throw new Test262Error(); })()]) { + +}; + +assert.throws(Test262Error, function() { + f([undefined]); +}); diff --git a/test/language/statements/async-generator/dstr-ary-ptrn-elem-id-init-unresolvable.js b/test/language/statements/async-generator/dstr-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000..bb7cf1e2aa --- /dev/null +++ b/test/language/statements/async-generator/dstr-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-unresolvable.case +// - src/dstr-binding/error/async-gen-func-decl.template +/*--- +description: Destructuring initializer is an unresolvable reference (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + + +async function* f([ x = unresolvableReference ]) { + +}; + +assert.throws(ReferenceError, function() { + f([]); +}); diff --git a/test/language/statements/async-generator/dstr-ary-ptrn-elem-id-iter-step-err.js b/test/language/statements/async-generator/dstr-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000..10765a43c8 --- /dev/null +++ b/test/language/statements/async-generator/dstr-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-step-err.case +// - src/dstr-binding/error/async-gen-func-decl.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). +---*/ +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + throw new Test262Error(); + } + }; +}; + + +async function* f([x]) { + +}; + +assert.throws(Test262Error, function() { + f(g); +}); diff --git a/test/language/statements/async-generator/dstr-ary-ptrn-elem-id-iter-val-err.js b/test/language/statements/async-generator/dstr-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000..457ca71199 --- /dev/null +++ b/test/language/statements/async-generator/dstr-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-err.case +// - src/dstr-binding/error/async-gen-func-decl.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(v). +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + + +async function* f([x]) { + +}; + +assert.throws(Test262Error, function() { + f(g); +}); diff --git a/test/language/statements/async-generator/dstr-ary-ptrn-elem-obj-val-null.js b/test/language/statements/async-generator/dstr-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000..81ef1e0827 --- /dev/null +++ b/test/language/statements/async-generator/dstr-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,45 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-null.case +// - src/dstr-binding/error/async-gen-func-decl.template +/*--- +description: Nested object destructuring with a null value (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + + +async function* f([{ x }]) { + +}; + +assert.throws(TypeError, function() { + f([null]); +}); diff --git a/test/language/statements/async-generator/dstr-ary-ptrn-elem-obj-val-undef.js b/test/language/statements/async-generator/dstr-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000..8e4faa0d8c --- /dev/null +++ b/test/language/statements/async-generator/dstr-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,45 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-undef.case +// - src/dstr-binding/error/async-gen-func-decl.template +/*--- +description: Nested object destructuring with a value of `undefined` (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + + +async function* f([{ x }]) { + +}; + +assert.throws(TypeError, function() { + f([]); +}); diff --git a/test/language/statements/async-generator/dstr-ary-ptrn-elision-step-err.js b/test/language/statements/async-generator/dstr-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000..a561463c45 --- /dev/null +++ b/test/language/statements/async-generator/dstr-ary-ptrn-elision-step-err.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/async-gen-func-decl.template +/*--- +description: Elision advances iterator and forwards abrupt completions (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [generator, async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + +---*/ +var following = 0; +var iter =function* () { + throw new Test262Error(); + following += 1; +}(); + + +async function* f([,]) { + +}; + +assert.throws(Test262Error, function() { + f(iter); +}); + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); diff --git a/test/language/statements/async-generator/dstr-ary-ptrn-rest-id-elision-next-err.js b/test/language/statements/async-generator/dstr-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000..b8f8e8b9e4 --- /dev/null +++ b/test/language/statements/async-generator/dstr-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision-next-err.case +// - src/dstr-binding/error/async-gen-func-decl.template +/*--- +description: Rest element following elision elements (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [generators, async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. + +---*/ +var iter = (function*() { throw new Test262Error(); })(); + + +async function* f([, ...x]) { + +}; + +assert.throws(Test262Error, function() { + f(iter); +}); diff --git a/test/language/statements/async-generator/dstr-ary-ptrn-rest-id-iter-step-err.js b/test/language/statements/async-generator/dstr-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000..5090b301e6 --- /dev/null +++ b/test/language/statements/async-generator/dstr-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,49 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case +// - src/dstr-binding/error/async-gen-func-decl.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [generators, async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + a. If iteratorRecord.[[done]] is false, + i. Let next be IteratorStep(iteratorRecord.[[iterator]]). + ii. If next is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(next). + +---*/ +var first = 0; +var second = 0; +var iter = function*() { + first += 1; + throw new Test262Error(); + second += 1; +}(); + + +async function* f([...x]) { + +}; + +assert.throws(Test262Error, function() { + f(iter); +}); + +iter.next(); +assert.sameValue(first, 1); +assert.sameValue(second, 0, 'Iterator is closed following abrupt completion.'); diff --git a/test/language/statements/async-generator/dstr-ary-ptrn-rest-id-iter-val-err.js b/test/language/statements/async-generator/dstr-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000..b4b19fd4d8 --- /dev/null +++ b/test/language/statements/async-generator/dstr-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-val-err.case +// - src/dstr-binding/error/async-gen-func-decl.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [Symbol.iterator, async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + c. Let nextValue be IteratorValue(next). + d. If nextValue is an abrupt completion, set iteratorRecord.[[done]] to + true. + e. ReturnIfAbrupt(nextValue). + +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + + +async function* f([...x]) { + +}; + +assert.throws(Test262Error, function() { + f(iter); +}); diff --git a/test/language/statements/async-generator/dstr-dflt-ary-init-iter-get-err.js b/test/language/statements/async-generator/dstr-dflt-ary-init-iter-get-err.js new file mode 100644 index 0000000000..95c7e2c6a2 --- /dev/null +++ b/test/language/statements/async-generator/dstr-dflt-ary-init-iter-get-err.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/async-gen-func-decl-dflt.template +/*--- +description: Abrupt completion returned by GetIterator (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [Symbol.iterator, async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). + +---*/ +var iter = {}; +iter[Symbol.iterator] = function() { + throw new Test262Error(); +}; + + +async function* f([x] = iter) { + +}; + +assert.throws(Test262Error, function() { + f(); +}); diff --git a/test/language/statements/async-generator/dstr-dflt-ary-ptrn-elem-ary-val-null.js b/test/language/statements/async-generator/dstr-dflt-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000..1761b1c89e --- /dev/null +++ b/test/language/statements/async-generator/dstr-dflt-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,45 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-val-null.case +// - src/dstr-binding/error/async-gen-func-decl-dflt.template +/*--- +description: Nested array destructuring with a null value (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). +---*/ + + +async function* f([[x]] = [null]) { + +}; + +assert.throws(TypeError, function() { + f(); +}); diff --git a/test/language/statements/async-generator/dstr-dflt-ary-ptrn-elem-id-init-throws.js b/test/language/statements/async-generator/dstr-dflt-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000..1b9a0e17ff --- /dev/null +++ b/test/language/statements/async-generator/dstr-dflt-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-throws.case +// - src/dstr-binding/error/async-gen-func-decl-dflt.template +/*--- +description: Destructuring initializer returns an abrupt completion (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ + + +async function* f([x = (function() { throw new Test262Error(); })()] = [undefined]) { + +}; + +assert.throws(Test262Error, function() { + f(); +}); diff --git a/test/language/statements/async-generator/dstr-dflt-ary-ptrn-elem-id-init-unresolvable.js b/test/language/statements/async-generator/dstr-dflt-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000..a50022966e --- /dev/null +++ b/test/language/statements/async-generator/dstr-dflt-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-unresolvable.case +// - src/dstr-binding/error/async-gen-func-decl-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + + +async function* f([ x = unresolvableReference ] = []) { + +}; + +assert.throws(ReferenceError, function() { + f(); +}); diff --git a/test/language/statements/async-generator/dstr-dflt-ary-ptrn-elem-id-iter-step-err.js b/test/language/statements/async-generator/dstr-dflt-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000..074029a930 --- /dev/null +++ b/test/language/statements/async-generator/dstr-dflt-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-step-err.case +// - src/dstr-binding/error/async-gen-func-decl-dflt.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). +---*/ +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + throw new Test262Error(); + } + }; +}; + + +async function* f([x] = g) { + +}; + +assert.throws(Test262Error, function() { + f(); +}); diff --git a/test/language/statements/async-generator/dstr-dflt-ary-ptrn-elem-id-iter-val-err.js b/test/language/statements/async-generator/dstr-dflt-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000..90d7324f93 --- /dev/null +++ b/test/language/statements/async-generator/dstr-dflt-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-err.case +// - src/dstr-binding/error/async-gen-func-decl-dflt.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(v). +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + + +async function* f([x] = g) { + +}; + +assert.throws(Test262Error, function() { + f(); +}); diff --git a/test/language/statements/async-generator/dstr-dflt-ary-ptrn-elem-obj-val-null.js b/test/language/statements/async-generator/dstr-dflt-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000..2fdbcf8b2a --- /dev/null +++ b/test/language/statements/async-generator/dstr-dflt-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,45 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-null.case +// - src/dstr-binding/error/async-gen-func-decl-dflt.template +/*--- +description: Nested object destructuring with a null value (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + + +async function* f([{ x }] = [null]) { + +}; + +assert.throws(TypeError, function() { + f(); +}); diff --git a/test/language/statements/async-generator/dstr-dflt-ary-ptrn-elem-obj-val-undef.js b/test/language/statements/async-generator/dstr-dflt-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000..16d2487ad8 --- /dev/null +++ b/test/language/statements/async-generator/dstr-dflt-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,45 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-undef.case +// - src/dstr-binding/error/async-gen-func-decl-dflt.template +/*--- +description: Nested object destructuring with a value of `undefined` (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + + +async function* f([{ x }] = []) { + +}; + +assert.throws(TypeError, function() { + f(); +}); diff --git a/test/language/statements/async-generator/dstr-dflt-ary-ptrn-elision-step-err.js b/test/language/statements/async-generator/dstr-dflt-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000..4c0afc21a3 --- /dev/null +++ b/test/language/statements/async-generator/dstr-dflt-ary-ptrn-elision-step-err.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/async-gen-func-decl-dflt.template +/*--- +description: Elision advances iterator and forwards abrupt completions (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [generator, async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + +---*/ +var following = 0; +var iter =function* () { + throw new Test262Error(); + following += 1; +}(); + + +async function* f([,] = iter) { + +}; + +assert.throws(Test262Error, function() { + f(); +}); + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); diff --git a/test/language/statements/async-generator/dstr-dflt-ary-ptrn-rest-id-elision-next-err.js b/test/language/statements/async-generator/dstr-dflt-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000..209e7a67c2 --- /dev/null +++ b/test/language/statements/async-generator/dstr-dflt-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision-next-err.case +// - src/dstr-binding/error/async-gen-func-decl-dflt.template +/*--- +description: Rest element following elision elements (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [generators, async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. + +---*/ +var iter = (function*() { throw new Test262Error(); })(); + + +async function* f([, ...x] = iter) { + +}; + +assert.throws(Test262Error, function() { + f(); +}); diff --git a/test/language/statements/async-generator/dstr-dflt-ary-ptrn-rest-id-iter-step-err.js b/test/language/statements/async-generator/dstr-dflt-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000..b2d4c3c217 --- /dev/null +++ b/test/language/statements/async-generator/dstr-dflt-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,49 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case +// - src/dstr-binding/error/async-gen-func-decl-dflt.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [generators, async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + a. If iteratorRecord.[[done]] is false, + i. Let next be IteratorStep(iteratorRecord.[[iterator]]). + ii. If next is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(next). + +---*/ +var first = 0; +var second = 0; +var iter = function*() { + first += 1; + throw new Test262Error(); + second += 1; +}(); + + +async function* f([...x] = iter) { + +}; + +assert.throws(Test262Error, function() { + f(); +}); + +iter.next(); +assert.sameValue(first, 1); +assert.sameValue(second, 0, 'Iterator is closed following abrupt completion.'); diff --git a/test/language/statements/async-generator/dstr-dflt-ary-ptrn-rest-id-iter-val-err.js b/test/language/statements/async-generator/dstr-dflt-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000..1e151acb08 --- /dev/null +++ b/test/language/statements/async-generator/dstr-dflt-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-val-err.case +// - src/dstr-binding/error/async-gen-func-decl-dflt.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [Symbol.iterator, async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + c. Let nextValue be IteratorValue(next). + d. If nextValue is an abrupt completion, set iteratorRecord.[[done]] to + true. + e. ReturnIfAbrupt(nextValue). + +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + + +async function* f([...x] = iter) { + +}; + +assert.throws(Test262Error, function() { + f(); +}); diff --git a/test/language/statements/async-generator/dstr-dflt-obj-init-null.js b/test/language/statements/async-generator/dstr-dflt-obj-init-null.js new file mode 100644 index 0000000000..24ec17b186 --- /dev/null +++ b/test/language/statements/async-generator/dstr-dflt-obj-init-null.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/async-gen-func-decl-dflt.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + + +async function* f({} = null) { + +}; + +assert.throws(TypeError, function() { + f(); +}); diff --git a/test/language/statements/async-generator/dstr-dflt-obj-init-undefined.js b/test/language/statements/async-generator/dstr-dflt-obj-init-undefined.js new file mode 100644 index 0000000000..2e430b0c6f --- /dev/null +++ b/test/language/statements/async-generator/dstr-dflt-obj-init-undefined.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/async-gen-func-decl-dflt.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + + +async function* f({} = undefined) { + +}; + +assert.throws(TypeError, function() { + f(); +}); diff --git a/test/language/statements/async-generator/dstr-dflt-obj-ptrn-id-get-value-err.js b/test/language/statements/async-generator/dstr-dflt-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000..be16d34221 --- /dev/null +++ b/test/language/statements/async-generator/dstr-dflt-obj-ptrn-id-get-value-err.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-get-value-err.case +// - src/dstr-binding/error/async-gen-func-decl-dflt.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. Let v be GetV(value, propertyName). + 5. ReturnIfAbrupt(v). +---*/ +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + + +async function* f({ poisoned } = poisonedProperty) { + +}; + +assert.throws(Test262Error, function() { + f(); +}); diff --git a/test/language/statements/async-generator/dstr-dflt-obj-ptrn-id-init-throws.js b/test/language/statements/async-generator/dstr-dflt-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000..31da0af46e --- /dev/null +++ b/test/language/statements/async-generator/dstr-dflt-obj-ptrn-id-init-throws.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/async-gen-func-decl-dflt.template +/*--- +description: Error thrown when evaluating the initializer (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + + +async function* f({ x = thrower() } = {}) { + +}; + +assert.throws(Test262Error, function() { + f(); +}); diff --git a/test/language/statements/async-generator/dstr-dflt-obj-ptrn-id-init-unresolvable.js b/test/language/statements/async-generator/dstr-dflt-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000..e5649b7864 --- /dev/null +++ b/test/language/statements/async-generator/dstr-dflt-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/async-gen-func-decl-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + + +async function* f({ x = unresolvableReference } = {}) { + +}; + +assert.throws(ReferenceError, function() { + f(); +}); diff --git a/test/language/statements/async-generator/dstr-dflt-obj-ptrn-list-err.js b/test/language/statements/async-generator/dstr-dflt-obj-ptrn-list-err.js new file mode 100644 index 0000000000..a9c7ccfab3 --- /dev/null +++ b/test/language/statements/async-generator/dstr-dflt-obj-ptrn-list-err.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/async-gen-func-decl-dflt.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPropertyList : BindingPropertyList , BindingProperty + + 1. Let status be the result of performing BindingInitialization for + BindingPropertyList using value and environment as arguments. + 2. ReturnIfAbrupt(status). +---*/ +var initCount = 0; +function thrower() { + throw new Test262Error(); +} + + +async function* f({ a, b = thrower(), c = ++initCount } = {}) { + +}; + +assert.throws(Test262Error, function() { + f(); +}); + +assert.sameValue(initCount, 0); diff --git a/test/language/statements/async-generator/dstr-dflt-obj-ptrn-prop-ary-value-null.js b/test/language/statements/async-generator/dstr-dflt-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000..9bcb810fcd --- /dev/null +++ b/test/language/statements/async-generator/dstr-dflt-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,34 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-value-null.case +// - src/dstr-binding/error/async-gen-func-decl-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + + +async function* f({ w: [x, y, z] = [4, 5, 6] } = { w: null }) { + +}; + +assert.throws(TypeError, function() { + f(); +}); diff --git a/test/language/statements/async-generator/dstr-dflt-obj-ptrn-prop-eval-err.js b/test/language/statements/async-generator/dstr-dflt-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000..05be77b596 --- /dev/null +++ b/test/language/statements/async-generator/dstr-dflt-obj-ptrn-prop-eval-err.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/async-gen-func-decl-dflt.template +/*--- +description: Evaluation of property name returns an abrupt completion (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingProperty : PropertyName : BindingElement + + 1. Let P be the result of evaluating PropertyName + 2. ReturnIfAbrupt(P). +---*/ +function thrower() { + throw new Test262Error(); +} + + +async function* f({ [thrower()]: x } = {}) { + +}; + +assert.throws(Test262Error, function() { + f(); +}); diff --git a/test/language/statements/async-generator/dstr-dflt-obj-ptrn-prop-id-get-value-err.js b/test/language/statements/async-generator/dstr-dflt-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000..f4cd83fa47 --- /dev/null +++ b/test/language/statements/async-generator/dstr-dflt-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-get-value-err.case +// - src/dstr-binding/error/async-gen-func-decl-dflt.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. Let v be GetV(value, propertyName). + 2. ReturnIfAbrupt(v). +---*/ +var initEvalCount = 0; +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + + +async function* f({ poisoned: x = ++initEvalCount } = poisonedProperty) { + +}; + +assert.throws(Test262Error, function() { + f(); +}); + +assert.sameValue(initEvalCount, 0); diff --git a/test/language/statements/async-generator/dstr-dflt-obj-ptrn-prop-id-init-throws.js b/test/language/statements/async-generator/dstr-dflt-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000..7d787e12cb --- /dev/null +++ b/test/language/statements/async-generator/dstr-dflt-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-throws.case +// - src/dstr-binding/error/async-gen-func-decl-dflt.template +/*--- +description: Error thrown when evaluating the initializer (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + + +async function* f({ x: y = thrower() } = {}) { + +}; + +assert.throws(Test262Error, function() { + f(); +}); diff --git a/test/language/statements/async-generator/dstr-dflt-obj-ptrn-prop-id-init-unresolvable.js b/test/language/statements/async-generator/dstr-dflt-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000..ba1cd4d0cd --- /dev/null +++ b/test/language/statements/async-generator/dstr-dflt-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-unresolvable.case +// - src/dstr-binding/error/async-gen-func-decl-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + + +async function* f({ x: y = unresolvableReference } = {}) { + +}; + +assert.throws(ReferenceError, function() { + f(); +}); diff --git a/test/language/statements/async-generator/dstr-dflt-obj-ptrn-prop-obj-value-null.js b/test/language/statements/async-generator/dstr-dflt-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000..f2dce22d0c --- /dev/null +++ b/test/language/statements/async-generator/dstr-dflt-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,34 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-null.case +// - src/dstr-binding/error/async-gen-func-decl-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + + +async function* f({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: null }) { + +}; + +assert.throws(TypeError, function() { + f(); +}); diff --git a/test/language/statements/async-generator/dstr-dflt-obj-ptrn-prop-obj-value-undef.js b/test/language/statements/async-generator/dstr-dflt-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000..e65e7483c9 --- /dev/null +++ b/test/language/statements/async-generator/dstr-dflt-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,34 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-undef.case +// - src/dstr-binding/error/async-gen-func-decl-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (async generator function declaration (default parameter)) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + + +async function* f({ w: { x, y, z } = undefined } = { }) { + +}; + +assert.throws(TypeError, function() { + f(); +}); diff --git a/test/language/statements/async-generator/dstr-obj-init-null.js b/test/language/statements/async-generator/dstr-obj-init-null.js new file mode 100644 index 0000000000..bcae91c153 --- /dev/null +++ b/test/language/statements/async-generator/dstr-obj-init-null.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/async-gen-func-decl.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + + +async function* f({}) { + +}; + +assert.throws(TypeError, function() { + f(null); +}); diff --git a/test/language/statements/async-generator/dstr-obj-init-undefined.js b/test/language/statements/async-generator/dstr-obj-init-undefined.js new file mode 100644 index 0000000000..0bfb81a197 --- /dev/null +++ b/test/language/statements/async-generator/dstr-obj-init-undefined.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/async-gen-func-decl.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + + +async function* f({}) { + +}; + +assert.throws(TypeError, function() { + f(undefined); +}); diff --git a/test/language/statements/async-generator/dstr-obj-ptrn-id-get-value-err.js b/test/language/statements/async-generator/dstr-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000..b74b1fc6c0 --- /dev/null +++ b/test/language/statements/async-generator/dstr-obj-ptrn-id-get-value-err.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-get-value-err.case +// - src/dstr-binding/error/async-gen-func-decl.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. Let v be GetV(value, propertyName). + 5. ReturnIfAbrupt(v). +---*/ +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + + +async function* f({ poisoned }) { + +}; + +assert.throws(Test262Error, function() { + f(poisonedProperty); +}); diff --git a/test/language/statements/async-generator/dstr-obj-ptrn-id-init-throws.js b/test/language/statements/async-generator/dstr-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000..c8ec8b3633 --- /dev/null +++ b/test/language/statements/async-generator/dstr-obj-ptrn-id-init-throws.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/async-gen-func-decl.template +/*--- +description: Error thrown when evaluating the initializer (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + + +async function* f({ x = thrower() }) { + +}; + +assert.throws(Test262Error, function() { + f({}); +}); diff --git a/test/language/statements/async-generator/dstr-obj-ptrn-id-init-unresolvable.js b/test/language/statements/async-generator/dstr-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000..d2d3cfce67 --- /dev/null +++ b/test/language/statements/async-generator/dstr-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/async-gen-func-decl.template +/*--- +description: Destructuring initializer is an unresolvable reference (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + + +async function* f({ x = unresolvableReference }) { + +}; + +assert.throws(ReferenceError, function() { + f({}); +}); diff --git a/test/language/statements/async-generator/dstr-obj-ptrn-list-err.js b/test/language/statements/async-generator/dstr-obj-ptrn-list-err.js new file mode 100644 index 0000000000..b9d897b759 --- /dev/null +++ b/test/language/statements/async-generator/dstr-obj-ptrn-list-err.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/async-gen-func-decl.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPropertyList : BindingPropertyList , BindingProperty + + 1. Let status be the result of performing BindingInitialization for + BindingPropertyList using value and environment as arguments. + 2. ReturnIfAbrupt(status). +---*/ +var initCount = 0; +function thrower() { + throw new Test262Error(); +} + + +async function* f({ a, b = thrower(), c = ++initCount }) { + +}; + +assert.throws(Test262Error, function() { + f({}); +}); + +assert.sameValue(initCount, 0); diff --git a/test/language/statements/async-generator/dstr-obj-ptrn-prop-ary-value-null.js b/test/language/statements/async-generator/dstr-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000..5e5c4777c9 --- /dev/null +++ b/test/language/statements/async-generator/dstr-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,34 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-value-null.case +// - src/dstr-binding/error/async-gen-func-decl.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + + +async function* f({ w: [x, y, z] = [4, 5, 6] }) { + +}; + +assert.throws(TypeError, function() { + f({ w: null }); +}); diff --git a/test/language/statements/async-generator/dstr-obj-ptrn-prop-eval-err.js b/test/language/statements/async-generator/dstr-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000..b55a098a36 --- /dev/null +++ b/test/language/statements/async-generator/dstr-obj-ptrn-prop-eval-err.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/async-gen-func-decl.template +/*--- +description: Evaluation of property name returns an abrupt completion (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingProperty : PropertyName : BindingElement + + 1. Let P be the result of evaluating PropertyName + 2. ReturnIfAbrupt(P). +---*/ +function thrower() { + throw new Test262Error(); +} + + +async function* f({ [thrower()]: x }) { + +}; + +assert.throws(Test262Error, function() { + f({}); +}); diff --git a/test/language/statements/async-generator/dstr-obj-ptrn-prop-id-get-value-err.js b/test/language/statements/async-generator/dstr-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000..232e0200ac --- /dev/null +++ b/test/language/statements/async-generator/dstr-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-get-value-err.case +// - src/dstr-binding/error/async-gen-func-decl.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. Let v be GetV(value, propertyName). + 2. ReturnIfAbrupt(v). +---*/ +var initEvalCount = 0; +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + + +async function* f({ poisoned: x = ++initEvalCount }) { + +}; + +assert.throws(Test262Error, function() { + f(poisonedProperty); +}); + +assert.sameValue(initEvalCount, 0); diff --git a/test/language/statements/async-generator/dstr-obj-ptrn-prop-id-init-throws.js b/test/language/statements/async-generator/dstr-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000..67c17079b3 --- /dev/null +++ b/test/language/statements/async-generator/dstr-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-throws.case +// - src/dstr-binding/error/async-gen-func-decl.template +/*--- +description: Error thrown when evaluating the initializer (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + + +async function* f({ x: y = thrower() }) { + +}; + +assert.throws(Test262Error, function() { + f({}); +}); diff --git a/test/language/statements/async-generator/dstr-obj-ptrn-prop-id-init-unresolvable.js b/test/language/statements/async-generator/dstr-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000..f80ec52b26 --- /dev/null +++ b/test/language/statements/async-generator/dstr-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-unresolvable.case +// - src/dstr-binding/error/async-gen-func-decl.template +/*--- +description: Destructuring initializer is an unresolvable reference (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + + +async function* f({ x: y = unresolvableReference }) { + +}; + +assert.throws(ReferenceError, function() { + f({}); +}); diff --git a/test/language/statements/async-generator/dstr-obj-ptrn-prop-obj-value-null.js b/test/language/statements/async-generator/dstr-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000..256653bd51 --- /dev/null +++ b/test/language/statements/async-generator/dstr-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,34 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-null.case +// - src/dstr-binding/error/async-gen-func-decl.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + + +async function* f({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) { + +}; + +assert.throws(TypeError, function() { + f({ w: null }); +}); diff --git a/test/language/statements/async-generator/dstr-obj-ptrn-prop-obj-value-undef.js b/test/language/statements/async-generator/dstr-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000..6d1da17814 --- /dev/null +++ b/test/language/statements/async-generator/dstr-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,34 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-undef.case +// - src/dstr-binding/error/async-gen-func-decl.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (async generator function declaration) +esid: sec-asyncgenerator-definitions-instantiatefunctionobject +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier + ( FormalParameters ) { AsyncGeneratorBody } + + [...] + 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, + scope, strict). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + + +async function* f({ w: { x, y, z } = undefined }) { + +}; + +assert.throws(TypeError, function() { + f({ }); +}); diff --git a/test/language/statements/class/dstr-async-gen-meth-ary-init-iter-get-err.js b/test/language/statements/class/dstr-async-gen-meth-ary-init-iter-get-err.js new file mode 100644 index 0000000000..2a922d8fb6 --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-ary-init-iter-get-err.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth.template +/*--- +description: Abrupt completion returned by GetIterator (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [Symbol.iterator, 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). + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). + +---*/ +var iter = {}; +iter[Symbol.iterator] = function() { + throw new Test262Error(); +}; + + +class C { + async *method([x]) { + + } +}; + +var method = C.prototype.method; + +assert.throws(Test262Error, function() { + method(iter); +}); diff --git a/test/language/statements/class/dstr-async-gen-meth-ary-ptrn-elem-ary-val-null.js b/test/language/statements/class/dstr-async-gen-meth-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000..da4dc68222 --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-val-null.case +// - src/dstr-binding/error/cls-decl-async-gen-meth.template +/*--- +description: Nested array destructuring with a null value (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). +---*/ + + +class C { + async *method([[x]]) { + + } +}; + +var method = C.prototype.method; + +assert.throws(TypeError, function() { + method([null]); +}); diff --git a/test/language/statements/class/dstr-async-gen-meth-ary-ptrn-elem-id-init-throws.js b/test/language/statements/class/dstr-async-gen-meth-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000..fdaac2edae --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-throws.case +// - src/dstr-binding/error/cls-decl-async-gen-meth.template +/*--- +description: Destructuring initializer returns an abrupt completion (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ + + +class C { + async *method([x = (function() { throw new Test262Error(); })()]) { + + } +}; + +var method = C.prototype.method; + +assert.throws(Test262Error, function() { + method([undefined]); +}); diff --git a/test/language/statements/class/dstr-async-gen-meth-ary-ptrn-elem-id-init-unresolvable.js b/test/language/statements/class/dstr-async-gen-meth-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000..20ecea2619 --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-unresolvable.case +// - src/dstr-binding/error/cls-decl-async-gen-meth.template +/*--- +description: Destructuring initializer is an unresolvable reference (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + + +class C { + async *method([ x = unresolvableReference ]) { + + } +}; + +var method = C.prototype.method; + +assert.throws(ReferenceError, function() { + method([]); +}); diff --git a/test/language/statements/class/dstr-async-gen-meth-ary-ptrn-elem-id-iter-step-err.js b/test/language/statements/class/dstr-async-gen-meth-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000..a0a776bb9e --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-step-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). +---*/ +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + throw new Test262Error(); + } + }; +}; + + +class C { + async *method([x]) { + + } +}; + +var method = C.prototype.method; + +assert.throws(Test262Error, function() { + method(g); +}); diff --git a/test/language/statements/class/dstr-async-gen-meth-ary-ptrn-elem-id-iter-val-err.js b/test/language/statements/class/dstr-async-gen-meth-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000..50d8810bd9 --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(v). +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + + +class C { + async *method([x]) { + + } +}; + +var method = C.prototype.method; + +assert.throws(Test262Error, function() { + method(g); +}); diff --git a/test/language/statements/class/dstr-async-gen-meth-ary-ptrn-elem-obj-val-null.js b/test/language/statements/class/dstr-async-gen-meth-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000..f6f65f2969 --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-null.case +// - src/dstr-binding/error/cls-decl-async-gen-meth.template +/*--- +description: Nested object destructuring with a null value (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + + +class C { + async *method([{ x }]) { + + } +}; + +var method = C.prototype.method; + +assert.throws(TypeError, function() { + method([null]); +}); diff --git a/test/language/statements/class/dstr-async-gen-meth-ary-ptrn-elem-obj-val-undef.js b/test/language/statements/class/dstr-async-gen-meth-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000..bf373068c8 --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-undef.case +// - src/dstr-binding/error/cls-decl-async-gen-meth.template +/*--- +description: Nested object destructuring with a value of `undefined` (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + + +class C { + async *method([{ x }]) { + + } +}; + +var method = C.prototype.method; + +assert.throws(TypeError, function() { + method([]); +}); diff --git a/test/language/statements/class/dstr-async-gen-meth-ary-ptrn-elision-step-err.js b/test/language/statements/class/dstr-async-gen-meth-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000..6d0fd3b4f5 --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-ary-ptrn-elision-step-err.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth.template +/*--- +description: Elision advances iterator and forwards abrupt completions (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generator, 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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + +---*/ +var following = 0; +var iter =function* () { + throw new Test262Error(); + following += 1; +}(); + + +class C { + async *method([,]) { + + } +}; + +var method = C.prototype.method; + +assert.throws(Test262Error, function() { + method(iter); +}); + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); diff --git a/test/language/statements/class/dstr-async-gen-meth-ary-ptrn-rest-id-elision-next-err.js b/test/language/statements/class/dstr-async-gen-meth-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000..24980d416a --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision-next-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth.template +/*--- +description: Rest element following elision elements (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, 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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. + +---*/ +var iter = (function*() { throw new Test262Error(); })(); + + +class C { + async *method([, ...x]) { + + } +}; + +var method = C.prototype.method; + +assert.throws(Test262Error, function() { + method(iter); +}); diff --git a/test/language/statements/class/dstr-async-gen-meth-ary-ptrn-rest-id-iter-step-err.js b/test/language/statements/class/dstr-async-gen-meth-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000..3219e6abf9 --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, 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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + a. If iteratorRecord.[[done]] is false, + i. Let next be IteratorStep(iteratorRecord.[[iterator]]). + ii. If next is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(next). + +---*/ +var first = 0; +var second = 0; +var iter = function*() { + first += 1; + throw new Test262Error(); + second += 1; +}(); + + +class C { + async *method([...x]) { + + } +}; + +var method = C.prototype.method; + +assert.throws(Test262Error, function() { + method(iter); +}); + +iter.next(); +assert.sameValue(first, 1); +assert.sameValue(second, 0, 'Iterator is closed following abrupt completion.'); diff --git a/test/language/statements/class/dstr-async-gen-meth-ary-ptrn-rest-id-iter-val-err.js b/test/language/statements/class/dstr-async-gen-meth-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000..fad995b94e --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-val-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [Symbol.iterator, 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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + c. Let nextValue be IteratorValue(next). + d. If nextValue is an abrupt completion, set iteratorRecord.[[done]] to + true. + e. ReturnIfAbrupt(nextValue). + +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + + +class C { + async *method([...x]) { + + } +}; + +var method = C.prototype.method; + +assert.throws(Test262Error, function() { + method(iter); +}); diff --git a/test/language/statements/class/dstr-async-gen-meth-dflt-ary-init-iter-get-err.js b/test/language/statements/class/dstr-async-gen-meth-dflt-ary-init-iter-get-err.js new file mode 100644 index 0000000000..9462b9bb97 --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-dflt-ary-init-iter-get-err.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-dflt.template +/*--- +description: Abrupt completion returned by GetIterator (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [Symbol.iterator, 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). + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). + +---*/ +var iter = {}; +iter[Symbol.iterator] = function() { + throw new Test262Error(); +}; + + +class C { + async *method([x] = iter) { + + } +}; + +var method = C.prototype.method; + +assert.throws(Test262Error, function() { + method(); +}); diff --git a/test/language/statements/class/dstr-async-gen-meth-dflt-ary-ptrn-elem-ary-val-null.js b/test/language/statements/class/dstr-async-gen-meth-dflt-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000..38b3c12811 --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-dflt-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-val-null.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-dflt.template +/*--- +description: Nested array destructuring with a null value (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). +---*/ + + +class C { + async *method([[x]] = [null]) { + + } +}; + +var method = C.prototype.method; + +assert.throws(TypeError, function() { + method(); +}); diff --git a/test/language/statements/class/dstr-async-gen-meth-dflt-ary-ptrn-elem-id-init-throws.js b/test/language/statements/class/dstr-async-gen-meth-dflt-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000..086d8f013c --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-dflt-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-throws.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-dflt.template +/*--- +description: Destructuring initializer returns an abrupt completion (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ + + +class C { + async *method([x = (function() { throw new Test262Error(); })()] = [undefined]) { + + } +}; + +var method = C.prototype.method; + +assert.throws(Test262Error, function() { + method(); +}); diff --git a/test/language/statements/class/dstr-async-gen-meth-dflt-ary-ptrn-elem-id-init-unresolvable.js b/test/language/statements/class/dstr-async-gen-meth-dflt-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000..0369330455 --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-dflt-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-unresolvable.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + + +class C { + async *method([ x = unresolvableReference ] = []) { + + } +}; + +var method = C.prototype.method; + +assert.throws(ReferenceError, function() { + method(); +}); diff --git a/test/language/statements/class/dstr-async-gen-meth-dflt-ary-ptrn-elem-id-iter-step-err.js b/test/language/statements/class/dstr-async-gen-meth-dflt-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000..bea21d853d --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-dflt-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-step-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-dflt.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). +---*/ +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + throw new Test262Error(); + } + }; +}; + + +class C { + async *method([x] = g) { + + } +}; + +var method = C.prototype.method; + +assert.throws(Test262Error, function() { + method(); +}); diff --git a/test/language/statements/class/dstr-async-gen-meth-dflt-ary-ptrn-elem-id-iter-val-err.js b/test/language/statements/class/dstr-async-gen-meth-dflt-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000..8aa3a0aa71 --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-dflt-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-dflt.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(v). +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + + +class C { + async *method([x] = g) { + + } +}; + +var method = C.prototype.method; + +assert.throws(Test262Error, function() { + method(); +}); diff --git a/test/language/statements/class/dstr-async-gen-meth-dflt-ary-ptrn-elem-obj-val-null.js b/test/language/statements/class/dstr-async-gen-meth-dflt-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000..704d720b88 --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-dflt-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-null.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-dflt.template +/*--- +description: Nested object destructuring with a null value (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + + +class C { + async *method([{ x }] = [null]) { + + } +}; + +var method = C.prototype.method; + +assert.throws(TypeError, function() { + method(); +}); diff --git a/test/language/statements/class/dstr-async-gen-meth-dflt-ary-ptrn-elem-obj-val-undef.js b/test/language/statements/class/dstr-async-gen-meth-dflt-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000..a88673357a --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-dflt-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-undef.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-dflt.template +/*--- +description: Nested object destructuring with a value of `undefined` (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + + +class C { + async *method([{ x }] = []) { + + } +}; + +var method = C.prototype.method; + +assert.throws(TypeError, function() { + method(); +}); diff --git a/test/language/statements/class/dstr-async-gen-meth-dflt-ary-ptrn-elision-step-err.js b/test/language/statements/class/dstr-async-gen-meth-dflt-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000..1047036c55 --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-dflt-ary-ptrn-elision-step-err.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-dflt.template +/*--- +description: Elision advances iterator and forwards abrupt completions (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generator, 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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + +---*/ +var following = 0; +var iter =function* () { + throw new Test262Error(); + following += 1; +}(); + + +class C { + async *method([,] = iter) { + + } +}; + +var method = C.prototype.method; + +assert.throws(Test262Error, function() { + method(); +}); + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); diff --git a/test/language/statements/class/dstr-async-gen-meth-dflt-ary-ptrn-rest-id-elision-next-err.js b/test/language/statements/class/dstr-async-gen-meth-dflt-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000..cfa3702509 --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-dflt-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision-next-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-dflt.template +/*--- +description: Rest element following elision elements (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, 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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. + +---*/ +var iter = (function*() { throw new Test262Error(); })(); + + +class C { + async *method([, ...x] = iter) { + + } +}; + +var method = C.prototype.method; + +assert.throws(Test262Error, function() { + method(); +}); diff --git a/test/language/statements/class/dstr-async-gen-meth-dflt-ary-ptrn-rest-id-iter-step-err.js b/test/language/statements/class/dstr-async-gen-meth-dflt-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000..61fd4f5bc6 --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-dflt-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-dflt.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, 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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + a. If iteratorRecord.[[done]] is false, + i. Let next be IteratorStep(iteratorRecord.[[iterator]]). + ii. If next is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(next). + +---*/ +var first = 0; +var second = 0; +var iter = function*() { + first += 1; + throw new Test262Error(); + second += 1; +}(); + + +class C { + async *method([...x] = iter) { + + } +}; + +var method = C.prototype.method; + +assert.throws(Test262Error, function() { + method(); +}); + +iter.next(); +assert.sameValue(first, 1); +assert.sameValue(second, 0, 'Iterator is closed following abrupt completion.'); diff --git a/test/language/statements/class/dstr-async-gen-meth-dflt-ary-ptrn-rest-id-iter-val-err.js b/test/language/statements/class/dstr-async-gen-meth-dflt-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000..9692abd027 --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-dflt-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-val-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-dflt.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [Symbol.iterator, 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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + c. Let nextValue be IteratorValue(next). + d. If nextValue is an abrupt completion, set iteratorRecord.[[done]] to + true. + e. ReturnIfAbrupt(nextValue). + +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + + +class C { + async *method([...x] = iter) { + + } +}; + +var method = C.prototype.method; + +assert.throws(Test262Error, function() { + method(); +}); diff --git a/test/language/statements/class/dstr-async-gen-meth-dflt-obj-init-null.js b/test/language/statements/class/dstr-async-gen-meth-dflt-obj-init-null.js new file mode 100644 index 0000000000..0e114bc8b5 --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-dflt-obj-init-null.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-dflt.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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). + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + + +class C { + async *method({} = null) { + + } +}; + +var method = C.prototype.method; + +assert.throws(TypeError, function() { + method(); +}); diff --git a/test/language/statements/class/dstr-async-gen-meth-dflt-obj-init-undefined.js b/test/language/statements/class/dstr-async-gen-meth-dflt-obj-init-undefined.js new file mode 100644 index 0000000000..372ca0791c --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-dflt-obj-init-undefined.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-dflt.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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). + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + + +class C { + async *method({} = undefined) { + + } +}; + +var method = C.prototype.method; + +assert.throws(TypeError, function() { + method(); +}); diff --git a/test/language/statements/class/dstr-async-gen-meth-dflt-obj-ptrn-id-get-value-err.js b/test/language/statements/class/dstr-async-gen-meth-dflt-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000..15d5a6acd2 --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-dflt-obj-ptrn-id-get-value-err.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-get-value-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-dflt.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. Let v be GetV(value, propertyName). + 5. ReturnIfAbrupt(v). +---*/ +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + + +class C { + async *method({ poisoned } = poisonedProperty) { + + } +}; + +var method = C.prototype.method; + +assert.throws(Test262Error, function() { + method(); +}); diff --git a/test/language/statements/class/dstr-async-gen-meth-dflt-obj-ptrn-id-init-throws.js b/test/language/statements/class/dstr-async-gen-meth-dflt-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000..3bdac23264 --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-dflt-obj-ptrn-id-init-throws.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-dflt.template +/*--- +description: Error thrown when evaluating the initializer (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + + +class C { + async *method({ x = thrower() } = {}) { + + } +}; + +var method = C.prototype.method; + +assert.throws(Test262Error, function() { + method(); +}); diff --git a/test/language/statements/class/dstr-async-gen-meth-dflt-obj-ptrn-id-init-unresolvable.js b/test/language/statements/class/dstr-async-gen-meth-dflt-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000..fb795173ff --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-dflt-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + + +class C { + async *method({ x = unresolvableReference } = {}) { + + } +}; + +var method = C.prototype.method; + +assert.throws(ReferenceError, function() { + method(); +}); diff --git a/test/language/statements/class/dstr-async-gen-meth-dflt-obj-ptrn-list-err.js b/test/language/statements/class/dstr-async-gen-meth-dflt-obj-ptrn-list-err.js new file mode 100644 index 0000000000..012ee47baf --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-dflt-obj-ptrn-list-err.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-dflt.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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). + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPropertyList : BindingPropertyList , BindingProperty + + 1. Let status be the result of performing BindingInitialization for + BindingPropertyList using value and environment as arguments. + 2. ReturnIfAbrupt(status). +---*/ +var initCount = 0; +function thrower() { + throw new Test262Error(); +} + + +class C { + async *method({ a, b = thrower(), c = ++initCount } = {}) { + + } +}; + +var method = C.prototype.method; + +assert.throws(Test262Error, function() { + method(); +}); + +assert.sameValue(initCount, 0); diff --git a/test/language/statements/class/dstr-async-gen-meth-dflt-obj-ptrn-prop-ary-value-null.js b/test/language/statements/class/dstr-async-gen-meth-dflt-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000..a9d5c670b5 --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-dflt-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-value-null.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + + +class C { + async *method({ w: [x, y, z] = [4, 5, 6] } = { w: null }) { + + } +}; + +var method = C.prototype.method; + +assert.throws(TypeError, function() { + method(); +}); diff --git a/test/language/statements/class/dstr-async-gen-meth-dflt-obj-ptrn-prop-eval-err.js b/test/language/statements/class/dstr-async-gen-meth-dflt-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000..23f3bb04b6 --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-dflt-obj-ptrn-prop-eval-err.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-dflt.template +/*--- +description: Evaluation of property name returns an abrupt completion (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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). + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingProperty : PropertyName : BindingElement + + 1. Let P be the result of evaluating PropertyName + 2. ReturnIfAbrupt(P). +---*/ +function thrower() { + throw new Test262Error(); +} + + +class C { + async *method({ [thrower()]: x } = {}) { + + } +}; + +var method = C.prototype.method; + +assert.throws(Test262Error, function() { + method(); +}); diff --git a/test/language/statements/class/dstr-async-gen-meth-dflt-obj-ptrn-prop-id-get-value-err.js b/test/language/statements/class/dstr-async-gen-meth-dflt-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000..afed2e96ea --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-dflt-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-get-value-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-dflt.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. Let v be GetV(value, propertyName). + 2. ReturnIfAbrupt(v). +---*/ +var initEvalCount = 0; +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + + +class C { + async *method({ poisoned: x = ++initEvalCount } = poisonedProperty) { + + } +}; + +var method = C.prototype.method; + +assert.throws(Test262Error, function() { + method(); +}); + +assert.sameValue(initEvalCount, 0); diff --git a/test/language/statements/class/dstr-async-gen-meth-dflt-obj-ptrn-prop-id-init-throws.js b/test/language/statements/class/dstr-async-gen-meth-dflt-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000..ef7c2d3acc --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-dflt-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-throws.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-dflt.template +/*--- +description: Error thrown when evaluating the initializer (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + + +class C { + async *method({ x: y = thrower() } = {}) { + + } +}; + +var method = C.prototype.method; + +assert.throws(Test262Error, function() { + method(); +}); diff --git a/test/language/statements/class/dstr-async-gen-meth-dflt-obj-ptrn-prop-id-init-unresolvable.js b/test/language/statements/class/dstr-async-gen-meth-dflt-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000..2887bb472e --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-dflt-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-unresolvable.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + + +class C { + async *method({ x: y = unresolvableReference } = {}) { + + } +}; + +var method = C.prototype.method; + +assert.throws(ReferenceError, function() { + method(); +}); diff --git a/test/language/statements/class/dstr-async-gen-meth-dflt-obj-ptrn-prop-obj-value-null.js b/test/language/statements/class/dstr-async-gen-meth-dflt-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000..fbe213a09a --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-dflt-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-null.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + + +class C { + async *method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: null }) { + + } +}; + +var method = C.prototype.method; + +assert.throws(TypeError, function() { + method(); +}); diff --git a/test/language/statements/class/dstr-async-gen-meth-dflt-obj-ptrn-prop-obj-value-undef.js b/test/language/statements/class/dstr-async-gen-meth-dflt-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000..8f31dd5d28 --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-dflt-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-undef.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + + +class C { + async *method({ w: { x, y, z } = undefined } = { }) { + + } +}; + +var method = C.prototype.method; + +assert.throws(TypeError, function() { + method(); +}); diff --git a/test/language/statements/class/dstr-async-gen-meth-obj-init-null.js b/test/language/statements/class/dstr-async-gen-meth-obj-init-null.js new file mode 100644 index 0000000000..c13e2b6778 --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-obj-init-null.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/cls-decl-async-gen-meth.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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). + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + + +class C { + async *method({}) { + + } +}; + +var method = C.prototype.method; + +assert.throws(TypeError, function() { + method(null); +}); diff --git a/test/language/statements/class/dstr-async-gen-meth-obj-init-undefined.js b/test/language/statements/class/dstr-async-gen-meth-obj-init-undefined.js new file mode 100644 index 0000000000..f0180871f0 --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-obj-init-undefined.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/cls-decl-async-gen-meth.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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). + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + + +class C { + async *method({}) { + + } +}; + +var method = C.prototype.method; + +assert.throws(TypeError, function() { + method(undefined); +}); diff --git a/test/language/statements/class/dstr-async-gen-meth-obj-ptrn-id-get-value-err.js b/test/language/statements/class/dstr-async-gen-meth-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000..21e60342e0 --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-obj-ptrn-id-get-value-err.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-get-value-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. Let v be GetV(value, propertyName). + 5. ReturnIfAbrupt(v). +---*/ +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + + +class C { + async *method({ poisoned }) { + + } +}; + +var method = C.prototype.method; + +assert.throws(Test262Error, function() { + method(poisonedProperty); +}); diff --git a/test/language/statements/class/dstr-async-gen-meth-obj-ptrn-id-init-throws.js b/test/language/statements/class/dstr-async-gen-meth-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000..22c9090539 --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-obj-ptrn-id-init-throws.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/cls-decl-async-gen-meth.template +/*--- +description: Error thrown when evaluating the initializer (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + + +class C { + async *method({ x = thrower() }) { + + } +}; + +var method = C.prototype.method; + +assert.throws(Test262Error, function() { + method({}); +}); diff --git a/test/language/statements/class/dstr-async-gen-meth-obj-ptrn-id-init-unresolvable.js b/test/language/statements/class/dstr-async-gen-meth-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000..9b6548cbd1 --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/cls-decl-async-gen-meth.template +/*--- +description: Destructuring initializer is an unresolvable reference (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + + +class C { + async *method({ x = unresolvableReference }) { + + } +}; + +var method = C.prototype.method; + +assert.throws(ReferenceError, function() { + method({}); +}); diff --git a/test/language/statements/class/dstr-async-gen-meth-obj-ptrn-list-err.js b/test/language/statements/class/dstr-async-gen-meth-obj-ptrn-list-err.js new file mode 100644 index 0000000000..7d0162f775 --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-obj-ptrn-list-err.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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). + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPropertyList : BindingPropertyList , BindingProperty + + 1. Let status be the result of performing BindingInitialization for + BindingPropertyList using value and environment as arguments. + 2. ReturnIfAbrupt(status). +---*/ +var initCount = 0; +function thrower() { + throw new Test262Error(); +} + + +class C { + async *method({ a, b = thrower(), c = ++initCount }) { + + } +}; + +var method = C.prototype.method; + +assert.throws(Test262Error, function() { + method({}); +}); + +assert.sameValue(initCount, 0); diff --git a/test/language/statements/class/dstr-async-gen-meth-obj-ptrn-prop-ary-value-null.js b/test/language/statements/class/dstr-async-gen-meth-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000..9832e90c7b --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-value-null.case +// - src/dstr-binding/error/cls-decl-async-gen-meth.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + + +class C { + async *method({ w: [x, y, z] = [4, 5, 6] }) { + + } +}; + +var method = C.prototype.method; + +assert.throws(TypeError, function() { + method({ w: null }); +}); diff --git a/test/language/statements/class/dstr-async-gen-meth-obj-ptrn-prop-eval-err.js b/test/language/statements/class/dstr-async-gen-meth-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000..162d3d014c --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-obj-ptrn-prop-eval-err.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth.template +/*--- +description: Evaluation of property name returns an abrupt completion (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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). + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingProperty : PropertyName : BindingElement + + 1. Let P be the result of evaluating PropertyName + 2. ReturnIfAbrupt(P). +---*/ +function thrower() { + throw new Test262Error(); +} + + +class C { + async *method({ [thrower()]: x }) { + + } +}; + +var method = C.prototype.method; + +assert.throws(Test262Error, function() { + method({}); +}); diff --git a/test/language/statements/class/dstr-async-gen-meth-obj-ptrn-prop-id-get-value-err.js b/test/language/statements/class/dstr-async-gen-meth-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000..4cb559e500 --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-get-value-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. Let v be GetV(value, propertyName). + 2. ReturnIfAbrupt(v). +---*/ +var initEvalCount = 0; +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + + +class C { + async *method({ poisoned: x = ++initEvalCount }) { + + } +}; + +var method = C.prototype.method; + +assert.throws(Test262Error, function() { + method(poisonedProperty); +}); + +assert.sameValue(initEvalCount, 0); diff --git a/test/language/statements/class/dstr-async-gen-meth-obj-ptrn-prop-id-init-throws.js b/test/language/statements/class/dstr-async-gen-meth-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000..8a96184f1c --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-throws.case +// - src/dstr-binding/error/cls-decl-async-gen-meth.template +/*--- +description: Error thrown when evaluating the initializer (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + + +class C { + async *method({ x: y = thrower() }) { + + } +}; + +var method = C.prototype.method; + +assert.throws(Test262Error, function() { + method({}); +}); diff --git a/test/language/statements/class/dstr-async-gen-meth-obj-ptrn-prop-id-init-unresolvable.js b/test/language/statements/class/dstr-async-gen-meth-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000..b89e874122 --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-unresolvable.case +// - src/dstr-binding/error/cls-decl-async-gen-meth.template +/*--- +description: Destructuring initializer is an unresolvable reference (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + + +class C { + async *method({ x: y = unresolvableReference }) { + + } +}; + +var method = C.prototype.method; + +assert.throws(ReferenceError, function() { + method({}); +}); diff --git a/test/language/statements/class/dstr-async-gen-meth-obj-ptrn-prop-obj-value-null.js b/test/language/statements/class/dstr-async-gen-meth-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000..7aeb65cd50 --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-null.case +// - src/dstr-binding/error/cls-decl-async-gen-meth.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + + +class C { + async *method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) { + + } +}; + +var method = C.prototype.method; + +assert.throws(TypeError, function() { + method({ w: null }); +}); diff --git a/test/language/statements/class/dstr-async-gen-meth-obj-ptrn-prop-obj-value-undef.js b/test/language/statements/class/dstr-async-gen-meth-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000..7f696f0631 --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-undef.case +// - src/dstr-binding/error/cls-decl-async-gen-meth.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [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). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + + +class C { + async *method({ w: { x, y, z } = undefined }) { + + } +}; + +var method = C.prototype.method; + +assert.throws(TypeError, function() { + method({ }); +}); diff --git a/test/language/statements/class/dstr-async-gen-meth-static-ary-init-iter-get-err.js b/test/language/statements/class/dstr-async-gen-meth-static-ary-init-iter-get-err.js new file mode 100644 index 0000000000..8cb6388e1e --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-static-ary-init-iter-get-err.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static.template +/*--- +description: Abrupt completion returned by GetIterator (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, 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). + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). + +---*/ +var iter = {}; +iter[Symbol.iterator] = function() { + throw new Test262Error(); +}; + + +class C { + static async *method([x]) { + + } +}; + +var method = C.method; + +assert.throws(Test262Error, function() { + method(iter); +}); diff --git a/test/language/statements/class/dstr-async-gen-meth-static-ary-ptrn-elem-ary-val-null.js b/test/language/statements/class/dstr-async-gen-meth-static-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000..c4c94c78dc --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-static-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-val-null.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static.template +/*--- +description: Nested array destructuring with a null value (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). +---*/ + + +class C { + static async *method([[x]]) { + + } +}; + +var method = C.method; + +assert.throws(TypeError, function() { + method([null]); +}); diff --git a/test/language/statements/class/dstr-async-gen-meth-static-ary-ptrn-elem-id-init-throws.js b/test/language/statements/class/dstr-async-gen-meth-static-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000..ea096515e5 --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-static-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-throws.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static.template +/*--- +description: Destructuring initializer returns an abrupt completion (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ + + +class C { + static async *method([x = (function() { throw new Test262Error(); })()]) { + + } +}; + +var method = C.method; + +assert.throws(Test262Error, function() { + method([undefined]); +}); diff --git a/test/language/statements/class/dstr-async-gen-meth-static-ary-ptrn-elem-id-init-unresolvable.js b/test/language/statements/class/dstr-async-gen-meth-static-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000..1f20c8302a --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-static-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-unresolvable.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static.template +/*--- +description: Destructuring initializer is an unresolvable reference (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + + +class C { + static async *method([ x = unresolvableReference ]) { + + } +}; + +var method = C.method; + +assert.throws(ReferenceError, function() { + method([]); +}); diff --git a/test/language/statements/class/dstr-async-gen-meth-static-ary-ptrn-elem-id-iter-step-err.js b/test/language/statements/class/dstr-async-gen-meth-static-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000..1390ff9c30 --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-static-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-step-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). +---*/ +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + throw new Test262Error(); + } + }; +}; + + +class C { + static async *method([x]) { + + } +}; + +var method = C.method; + +assert.throws(Test262Error, function() { + method(g); +}); diff --git a/test/language/statements/class/dstr-async-gen-meth-static-ary-ptrn-elem-id-iter-val-err.js b/test/language/statements/class/dstr-async-gen-meth-static-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000..9dad88fd6e --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-static-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(v). +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + + +class C { + static async *method([x]) { + + } +}; + +var method = C.method; + +assert.throws(Test262Error, function() { + method(g); +}); diff --git a/test/language/statements/class/dstr-async-gen-meth-static-ary-ptrn-elem-obj-val-null.js b/test/language/statements/class/dstr-async-gen-meth-static-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000..3d6e21ecbc --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-static-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-null.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static.template +/*--- +description: Nested object destructuring with a null value (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + + +class C { + static async *method([{ x }]) { + + } +}; + +var method = C.method; + +assert.throws(TypeError, function() { + method([null]); +}); diff --git a/test/language/statements/class/dstr-async-gen-meth-static-ary-ptrn-elem-obj-val-undef.js b/test/language/statements/class/dstr-async-gen-meth-static-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000..53f442c617 --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-static-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-undef.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static.template +/*--- +description: Nested object destructuring with a value of `undefined` (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + + +class C { + static async *method([{ x }]) { + + } +}; + +var method = C.method; + +assert.throws(TypeError, function() { + method([]); +}); diff --git a/test/language/statements/class/dstr-async-gen-meth-static-ary-ptrn-elision-step-err.js b/test/language/statements/class/dstr-async-gen-meth-static-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000..a92bbcb7cf --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-static-ary-ptrn-elision-step-err.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static.template +/*--- +description: Elision advances iterator and forwards abrupt completions (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generator, 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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + +---*/ +var following = 0; +var iter =function* () { + throw new Test262Error(); + following += 1; +}(); + + +class C { + static async *method([,]) { + + } +}; + +var method = C.method; + +assert.throws(Test262Error, function() { + method(iter); +}); + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); diff --git a/test/language/statements/class/dstr-async-gen-meth-static-ary-ptrn-rest-id-elision-next-err.js b/test/language/statements/class/dstr-async-gen-meth-static-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000..e1e11f7ddd --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-static-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision-next-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static.template +/*--- +description: Rest element following elision elements (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, 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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. + +---*/ +var iter = (function*() { throw new Test262Error(); })(); + + +class C { + static async *method([, ...x]) { + + } +}; + +var method = C.method; + +assert.throws(Test262Error, function() { + method(iter); +}); diff --git a/test/language/statements/class/dstr-async-gen-meth-static-ary-ptrn-rest-id-iter-step-err.js b/test/language/statements/class/dstr-async-gen-meth-static-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000..32c449f375 --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-static-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, 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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + a. If iteratorRecord.[[done]] is false, + i. Let next be IteratorStep(iteratorRecord.[[iterator]]). + ii. If next is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(next). + +---*/ +var first = 0; +var second = 0; +var iter = function*() { + first += 1; + throw new Test262Error(); + second += 1; +}(); + + +class C { + static async *method([...x]) { + + } +}; + +var method = C.method; + +assert.throws(Test262Error, function() { + method(iter); +}); + +iter.next(); +assert.sameValue(first, 1); +assert.sameValue(second, 0, 'Iterator is closed following abrupt completion.'); diff --git a/test/language/statements/class/dstr-async-gen-meth-static-ary-ptrn-rest-id-iter-val-err.js b/test/language/statements/class/dstr-async-gen-meth-static-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000..ca1cadb9f6 --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-static-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-val-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, 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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + c. Let nextValue be IteratorValue(next). + d. If nextValue is an abrupt completion, set iteratorRecord.[[done]] to + true. + e. ReturnIfAbrupt(nextValue). + +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + + +class C { + static async *method([...x]) { + + } +}; + +var method = C.method; + +assert.throws(Test262Error, function() { + method(iter); +}); diff --git a/test/language/statements/class/dstr-async-gen-meth-static-dflt-ary-init-iter-get-err.js b/test/language/statements/class/dstr-async-gen-meth-static-dflt-ary-init-iter-get-err.js new file mode 100644 index 0000000000..593e504d16 --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-static-dflt-ary-init-iter-get-err.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Abrupt completion returned by GetIterator (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, 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). + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). + +---*/ +var iter = {}; +iter[Symbol.iterator] = function() { + throw new Test262Error(); +}; + + +class C { + static async *method([x] = iter) { + + } +}; + +var method = C.method; + +assert.throws(Test262Error, function() { + method(); +}); diff --git a/test/language/statements/class/dstr-async-gen-meth-static-dflt-ary-ptrn-elem-ary-val-null.js b/test/language/statements/class/dstr-async-gen-meth-static-dflt-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000..0ab774fc8e --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-static-dflt-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-val-null.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Nested array destructuring with a null value (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). +---*/ + + +class C { + static async *method([[x]] = [null]) { + + } +}; + +var method = C.method; + +assert.throws(TypeError, function() { + method(); +}); diff --git a/test/language/statements/class/dstr-async-gen-meth-static-dflt-ary-ptrn-elem-id-init-throws.js b/test/language/statements/class/dstr-async-gen-meth-static-dflt-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000..9c4b542732 --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-static-dflt-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-throws.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Destructuring initializer returns an abrupt completion (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ + + +class C { + static async *method([x = (function() { throw new Test262Error(); })()] = [undefined]) { + + } +}; + +var method = C.method; + +assert.throws(Test262Error, function() { + method(); +}); diff --git a/test/language/statements/class/dstr-async-gen-meth-static-dflt-ary-ptrn-elem-id-init-unresolvable.js b/test/language/statements/class/dstr-async-gen-meth-static-dflt-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000..ad01767067 --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-static-dflt-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-unresolvable.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + + +class C { + static async *method([ x = unresolvableReference ] = []) { + + } +}; + +var method = C.method; + +assert.throws(ReferenceError, function() { + method(); +}); diff --git a/test/language/statements/class/dstr-async-gen-meth-static-dflt-ary-ptrn-elem-id-iter-step-err.js b/test/language/statements/class/dstr-async-gen-meth-static-dflt-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000..18d14f5d6b --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-static-dflt-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-step-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). +---*/ +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + throw new Test262Error(); + } + }; +}; + + +class C { + static async *method([x] = g) { + + } +}; + +var method = C.method; + +assert.throws(Test262Error, function() { + method(); +}); diff --git a/test/language/statements/class/dstr-async-gen-meth-static-dflt-ary-ptrn-elem-id-iter-val-err.js b/test/language/statements/class/dstr-async-gen-meth-static-dflt-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000..b6c03cac04 --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-static-dflt-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(v). +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + + +class C { + static async *method([x] = g) { + + } +}; + +var method = C.method; + +assert.throws(Test262Error, function() { + method(); +}); diff --git a/test/language/statements/class/dstr-async-gen-meth-static-dflt-ary-ptrn-elem-obj-val-null.js b/test/language/statements/class/dstr-async-gen-meth-static-dflt-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000..e1269a2e3e --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-static-dflt-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-null.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Nested object destructuring with a null value (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + + +class C { + static async *method([{ x }] = [null]) { + + } +}; + +var method = C.method; + +assert.throws(TypeError, function() { + method(); +}); diff --git a/test/language/statements/class/dstr-async-gen-meth-static-dflt-ary-ptrn-elem-obj-val-undef.js b/test/language/statements/class/dstr-async-gen-meth-static-dflt-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000..84831450fb --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-static-dflt-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-undef.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Nested object destructuring with a value of `undefined` (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + + +class C { + static async *method([{ x }] = []) { + + } +}; + +var method = C.method; + +assert.throws(TypeError, function() { + method(); +}); diff --git a/test/language/statements/class/dstr-async-gen-meth-static-dflt-ary-ptrn-elision-step-err.js b/test/language/statements/class/dstr-async-gen-meth-static-dflt-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000..09fa821c2c --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-static-dflt-ary-ptrn-elision-step-err.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Elision advances iterator and forwards abrupt completions (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generator, 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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + +---*/ +var following = 0; +var iter =function* () { + throw new Test262Error(); + following += 1; +}(); + + +class C { + static async *method([,] = iter) { + + } +}; + +var method = C.method; + +assert.throws(Test262Error, function() { + method(); +}); + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); diff --git a/test/language/statements/class/dstr-async-gen-meth-static-dflt-ary-ptrn-rest-id-elision-next-err.js b/test/language/statements/class/dstr-async-gen-meth-static-dflt-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000..3aa9f2f1cb --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-static-dflt-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision-next-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Rest element following elision elements (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, 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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. + +---*/ +var iter = (function*() { throw new Test262Error(); })(); + + +class C { + static async *method([, ...x] = iter) { + + } +}; + +var method = C.method; + +assert.throws(Test262Error, function() { + method(); +}); diff --git a/test/language/statements/class/dstr-async-gen-meth-static-dflt-ary-ptrn-rest-id-iter-step-err.js b/test/language/statements/class/dstr-async-gen-meth-static-dflt-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000..548076cd13 --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-static-dflt-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, 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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + a. If iteratorRecord.[[done]] is false, + i. Let next be IteratorStep(iteratorRecord.[[iterator]]). + ii. If next is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(next). + +---*/ +var first = 0; +var second = 0; +var iter = function*() { + first += 1; + throw new Test262Error(); + second += 1; +}(); + + +class C { + static async *method([...x] = iter) { + + } +}; + +var method = C.method; + +assert.throws(Test262Error, function() { + method(); +}); + +iter.next(); +assert.sameValue(first, 1); +assert.sameValue(second, 0, 'Iterator is closed following abrupt completion.'); diff --git a/test/language/statements/class/dstr-async-gen-meth-static-dflt-ary-ptrn-rest-id-iter-val-err.js b/test/language/statements/class/dstr-async-gen-meth-static-dflt-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000..8059480c42 --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-static-dflt-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-val-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, 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). + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + c. Let nextValue be IteratorValue(next). + d. If nextValue is an abrupt completion, set iteratorRecord.[[done]] to + true. + e. ReturnIfAbrupt(nextValue). + +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + + +class C { + static async *method([...x] = iter) { + + } +}; + +var method = C.method; + +assert.throws(Test262Error, function() { + method(); +}); diff --git a/test/language/statements/class/dstr-async-gen-meth-static-dflt-obj-init-null.js b/test/language/statements/class/dstr-async-gen-meth-static-dflt-obj-init-null.js new file mode 100644 index 0000000000..4d8c79aa01 --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-static-dflt-obj-init-null.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [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). + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + + +class C { + static async *method({} = null) { + + } +}; + +var method = C.method; + +assert.throws(TypeError, function() { + method(); +}); diff --git a/test/language/statements/class/dstr-async-gen-meth-static-dflt-obj-init-undefined.js b/test/language/statements/class/dstr-async-gen-meth-static-dflt-obj-init-undefined.js new file mode 100644 index 0000000000..e9b73d4b79 --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-static-dflt-obj-init-undefined.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [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). + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + + +class C { + static async *method({} = undefined) { + + } +}; + +var method = C.method; + +assert.throws(TypeError, function() { + method(); +}); diff --git a/test/language/statements/class/dstr-async-gen-meth-static-dflt-obj-ptrn-id-get-value-err.js b/test/language/statements/class/dstr-async-gen-meth-static-dflt-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000..3bf6c9dce9 --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-static-dflt-obj-ptrn-id-get-value-err.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-get-value-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [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). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. Let v be GetV(value, propertyName). + 5. ReturnIfAbrupt(v). +---*/ +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + + +class C { + static async *method({ poisoned } = poisonedProperty) { + + } +}; + +var method = C.method; + +assert.throws(Test262Error, function() { + method(); +}); diff --git a/test/language/statements/class/dstr-async-gen-meth-static-dflt-obj-ptrn-id-init-throws.js b/test/language/statements/class/dstr-async-gen-meth-static-dflt-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000..f259d69e7f --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-static-dflt-obj-ptrn-id-init-throws.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Error thrown when evaluating the initializer (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [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). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + + +class C { + static async *method({ x = thrower() } = {}) { + + } +}; + +var method = C.method; + +assert.throws(Test262Error, function() { + method(); +}); diff --git a/test/language/statements/class/dstr-async-gen-meth-static-dflt-obj-ptrn-id-init-unresolvable.js b/test/language/statements/class/dstr-async-gen-meth-static-dflt-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000..6dedbb7082 --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-static-dflt-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [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). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + + +class C { + static async *method({ x = unresolvableReference } = {}) { + + } +}; + +var method = C.method; + +assert.throws(ReferenceError, function() { + method(); +}); diff --git a/test/language/statements/class/dstr-async-gen-meth-static-dflt-obj-ptrn-list-err.js b/test/language/statements/class/dstr-async-gen-meth-static-dflt-obj-ptrn-list-err.js new file mode 100644 index 0000000000..ae315da352 --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-static-dflt-obj-ptrn-list-err.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [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). + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPropertyList : BindingPropertyList , BindingProperty + + 1. Let status be the result of performing BindingInitialization for + BindingPropertyList using value and environment as arguments. + 2. ReturnIfAbrupt(status). +---*/ +var initCount = 0; +function thrower() { + throw new Test262Error(); +} + + +class C { + static async *method({ a, b = thrower(), c = ++initCount } = {}) { + + } +}; + +var method = C.method; + +assert.throws(Test262Error, function() { + method(); +}); + +assert.sameValue(initCount, 0); diff --git a/test/language/statements/class/dstr-async-gen-meth-static-dflt-obj-ptrn-prop-ary-value-null.js b/test/language/statements/class/dstr-async-gen-meth-static-dflt-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000..86c2f3b85f --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-static-dflt-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-value-null.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [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). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + + +class C { + static async *method({ w: [x, y, z] = [4, 5, 6] } = { w: null }) { + + } +}; + +var method = C.method; + +assert.throws(TypeError, function() { + method(); +}); diff --git a/test/language/statements/class/dstr-async-gen-meth-static-dflt-obj-ptrn-prop-eval-err.js b/test/language/statements/class/dstr-async-gen-meth-static-dflt-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000..462469d732 --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-static-dflt-obj-ptrn-prop-eval-err.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Evaluation of property name returns an abrupt completion (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [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). + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingProperty : PropertyName : BindingElement + + 1. Let P be the result of evaluating PropertyName + 2. ReturnIfAbrupt(P). +---*/ +function thrower() { + throw new Test262Error(); +} + + +class C { + static async *method({ [thrower()]: x } = {}) { + + } +}; + +var method = C.method; + +assert.throws(Test262Error, function() { + method(); +}); diff --git a/test/language/statements/class/dstr-async-gen-meth-static-dflt-obj-ptrn-prop-id-get-value-err.js b/test/language/statements/class/dstr-async-gen-meth-static-dflt-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000..1f0bb84e32 --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-static-dflt-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-get-value-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [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). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. Let v be GetV(value, propertyName). + 2. ReturnIfAbrupt(v). +---*/ +var initEvalCount = 0; +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + + +class C { + static async *method({ poisoned: x = ++initEvalCount } = poisonedProperty) { + + } +}; + +var method = C.method; + +assert.throws(Test262Error, function() { + method(); +}); + +assert.sameValue(initEvalCount, 0); diff --git a/test/language/statements/class/dstr-async-gen-meth-static-dflt-obj-ptrn-prop-id-init-throws.js b/test/language/statements/class/dstr-async-gen-meth-static-dflt-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000..4b0e957400 --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-static-dflt-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-throws.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Error thrown when evaluating the initializer (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [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). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + + +class C { + static async *method({ x: y = thrower() } = {}) { + + } +}; + +var method = C.method; + +assert.throws(Test262Error, function() { + method(); +}); diff --git a/test/language/statements/class/dstr-async-gen-meth-static-dflt-obj-ptrn-prop-id-init-unresolvable.js b/test/language/statements/class/dstr-async-gen-meth-static-dflt-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000..afc8af792e --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-static-dflt-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-unresolvable.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [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). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + + +class C { + static async *method({ x: y = unresolvableReference } = {}) { + + } +}; + +var method = C.method; + +assert.throws(ReferenceError, function() { + method(); +}); diff --git a/test/language/statements/class/dstr-async-gen-meth-static-dflt-obj-ptrn-prop-obj-value-null.js b/test/language/statements/class/dstr-async-gen-meth-static-dflt-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000..d7f52de513 --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-static-dflt-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-null.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [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). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + + +class C { + static async *method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: null }) { + + } +}; + +var method = C.method; + +assert.throws(TypeError, function() { + method(); +}); diff --git a/test/language/statements/class/dstr-async-gen-meth-static-dflt-obj-ptrn-prop-obj-value-undef.js b/test/language/statements/class/dstr-async-gen-meth-static-dflt-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000..070c70bac0 --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-static-dflt-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-undef.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [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). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + + +class C { + static async *method({ w: { x, y, z } = undefined } = { }) { + + } +}; + +var method = C.method; + +assert.throws(TypeError, function() { + method(); +}); diff --git a/test/language/statements/class/dstr-async-gen-meth-static-obj-init-null.js b/test/language/statements/class/dstr-async-gen-meth-static-obj-init-null.js new file mode 100644 index 0000000000..f7fc13920e --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-static-obj-init-null.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [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). + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + + +class C { + static async *method({}) { + + } +}; + +var method = C.method; + +assert.throws(TypeError, function() { + method(null); +}); diff --git a/test/language/statements/class/dstr-async-gen-meth-static-obj-init-undefined.js b/test/language/statements/class/dstr-async-gen-meth-static-obj-init-undefined.js new file mode 100644 index 0000000000..a2776c8915 --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-static-obj-init-undefined.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [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). + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + + +class C { + static async *method({}) { + + } +}; + +var method = C.method; + +assert.throws(TypeError, function() { + method(undefined); +}); diff --git a/test/language/statements/class/dstr-async-gen-meth-static-obj-ptrn-id-get-value-err.js b/test/language/statements/class/dstr-async-gen-meth-static-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000..b184d51182 --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-static-obj-ptrn-id-get-value-err.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-get-value-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [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). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. Let v be GetV(value, propertyName). + 5. ReturnIfAbrupt(v). +---*/ +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + + +class C { + static async *method({ poisoned }) { + + } +}; + +var method = C.method; + +assert.throws(Test262Error, function() { + method(poisonedProperty); +}); diff --git a/test/language/statements/class/dstr-async-gen-meth-static-obj-ptrn-id-init-throws.js b/test/language/statements/class/dstr-async-gen-meth-static-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000..cc63c43bfa --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-static-obj-ptrn-id-init-throws.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static.template +/*--- +description: Error thrown when evaluating the initializer (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [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). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + + +class C { + static async *method({ x = thrower() }) { + + } +}; + +var method = C.method; + +assert.throws(Test262Error, function() { + method({}); +}); diff --git a/test/language/statements/class/dstr-async-gen-meth-static-obj-ptrn-id-init-unresolvable.js b/test/language/statements/class/dstr-async-gen-meth-static-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000..9126f229be --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-static-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static.template +/*--- +description: Destructuring initializer is an unresolvable reference (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [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). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + + +class C { + static async *method({ x = unresolvableReference }) { + + } +}; + +var method = C.method; + +assert.throws(ReferenceError, function() { + method({}); +}); diff --git a/test/language/statements/class/dstr-async-gen-meth-static-obj-ptrn-list-err.js b/test/language/statements/class/dstr-async-gen-meth-static-obj-ptrn-list-err.js new file mode 100644 index 0000000000..846631034c --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-static-obj-ptrn-list-err.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [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). + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPropertyList : BindingPropertyList , BindingProperty + + 1. Let status be the result of performing BindingInitialization for + BindingPropertyList using value and environment as arguments. + 2. ReturnIfAbrupt(status). +---*/ +var initCount = 0; +function thrower() { + throw new Test262Error(); +} + + +class C { + static async *method({ a, b = thrower(), c = ++initCount }) { + + } +}; + +var method = C.method; + +assert.throws(Test262Error, function() { + method({}); +}); + +assert.sameValue(initCount, 0); diff --git a/test/language/statements/class/dstr-async-gen-meth-static-obj-ptrn-prop-ary-value-null.js b/test/language/statements/class/dstr-async-gen-meth-static-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000..0aaf0dd9dd --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-static-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-value-null.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [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). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + + +class C { + static async *method({ w: [x, y, z] = [4, 5, 6] }) { + + } +}; + +var method = C.method; + +assert.throws(TypeError, function() { + method({ w: null }); +}); diff --git a/test/language/statements/class/dstr-async-gen-meth-static-obj-ptrn-prop-eval-err.js b/test/language/statements/class/dstr-async-gen-meth-static-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000..ec9c54b028 --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-static-obj-ptrn-prop-eval-err.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static.template +/*--- +description: Evaluation of property name returns an abrupt completion (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [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). + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingProperty : PropertyName : BindingElement + + 1. Let P be the result of evaluating PropertyName + 2. ReturnIfAbrupt(P). +---*/ +function thrower() { + throw new Test262Error(); +} + + +class C { + static async *method({ [thrower()]: x }) { + + } +}; + +var method = C.method; + +assert.throws(Test262Error, function() { + method({}); +}); diff --git a/test/language/statements/class/dstr-async-gen-meth-static-obj-ptrn-prop-id-get-value-err.js b/test/language/statements/class/dstr-async-gen-meth-static-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000..5a37e3c99b --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-static-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-get-value-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [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). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. Let v be GetV(value, propertyName). + 2. ReturnIfAbrupt(v). +---*/ +var initEvalCount = 0; +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + + +class C { + static async *method({ poisoned: x = ++initEvalCount }) { + + } +}; + +var method = C.method; + +assert.throws(Test262Error, function() { + method(poisonedProperty); +}); + +assert.sameValue(initEvalCount, 0); diff --git a/test/language/statements/class/dstr-async-gen-meth-static-obj-ptrn-prop-id-init-throws.js b/test/language/statements/class/dstr-async-gen-meth-static-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000..2b41aac5ac --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-static-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-throws.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static.template +/*--- +description: Error thrown when evaluating the initializer (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [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). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + + +class C { + static async *method({ x: y = thrower() }) { + + } +}; + +var method = C.method; + +assert.throws(Test262Error, function() { + method({}); +}); diff --git a/test/language/statements/class/dstr-async-gen-meth-static-obj-ptrn-prop-id-init-unresolvable.js b/test/language/statements/class/dstr-async-gen-meth-static-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000..21793d826f --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-static-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-unresolvable.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static.template +/*--- +description: Destructuring initializer is an unresolvable reference (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [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). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + + +class C { + static async *method({ x: y = unresolvableReference }) { + + } +}; + +var method = C.method; + +assert.throws(ReferenceError, function() { + method({}); +}); diff --git a/test/language/statements/class/dstr-async-gen-meth-static-obj-ptrn-prop-obj-value-null.js b/test/language/statements/class/dstr-async-gen-meth-static-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000..4428d114e5 --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-static-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-null.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [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). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + + +class C { + static async *method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) { + + } +}; + +var method = C.method; + +assert.throws(TypeError, function() { + method({ w: null }); +}); diff --git a/test/language/statements/class/dstr-async-gen-meth-static-obj-ptrn-prop-obj-value-undef.js b/test/language/statements/class/dstr-async-gen-meth-static-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000..5e80767e0c --- /dev/null +++ b/test/language/statements/class/dstr-async-gen-meth-static-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-undef.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [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). + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + + +class C { + static async *method({ w: { x, y, z } = undefined }) { + + } +}; + +var method = C.method; + +assert.throws(TypeError, function() { + method({ }); +});